Skip to content

Commit 34ee193

Browse files
committed
refactor: 增加取消动画逻辑
1 parent 441aee0 commit 34ee193

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/BootstrapBlazor/Components/Message/Message.razor.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@ export function show(id, msgId) {
1414
return
1515
}
1616

17-
const msgItem = { el, animationId: null }
18-
if (msg.items.find(i => i.el.id === msgId) === void 0) {
17+
let msgItem = msg.items.find(i => i.el.id === msgId)
18+
if (msgItem === void 0) {
19+
msgitem = { el, animationId: null }
1920
msg.items.push(msgItem)
2021
}
2122

23+
if (msgitem.animationId) {
24+
cancelAnimationFrame(msgitem.animationId);
25+
}
26+
2227
const autoHide = el.getAttribute('data-bb-autohide') === 'true';
2328
if (autoHide) {
2429
const delay = parseInt(el.getAttribute('data-bb-delay'));

0 commit comments

Comments
 (0)