Skip to content

Commit 04264dc

Browse files
committed
feat: 增加状态切换逻辑
1 parent 51739bb commit 04264dc

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/BootstrapBlazor/Components/Popover/Popover.razor.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,45 @@ export function init(id, options) {
99
}
1010
}
1111

12+
export function show(id, delay) {
13+
const el = document.getElementById(id)
14+
if (el) {
15+
const pop = bootstrap.Popover.getInstance(el);
16+
if (pop) {
17+
const handler = setTimeout(() => {
18+
clearTimeout(handler);
19+
pop.show();
20+
}, delay || 0);
21+
}
22+
}
23+
}
24+
25+
export function hide(id, delay) {
26+
const el = document.getElementById(id)
27+
if (el) {
28+
const pop = bootstrap.Popover.getInstance(el);
29+
if (pop) {
30+
const handler = setTimeout(() => {
31+
clearTimeout(handler);
32+
pop.hide();
33+
}, delay || 0);
34+
}
35+
}
36+
}
37+
38+
export function toggle(id, delay) {
39+
const el = document.getElementById(id)
40+
if (el) {
41+
const pop = bootstrap.Popover.getInstance(el);
42+
if (pop) {
43+
const handler = setTimeout(() => {
44+
clearTimeout(handler);
45+
pop.toggle();
46+
}, delay || 0);
47+
}
48+
}
49+
}
50+
1251
export function dispose(id) {
1352
const el = document.getElementById(id)
1453
if (el) {

0 commit comments

Comments
 (0)