@@ -14,12 +14,18 @@ export function show(id, msgId) {
1414 return
1515 }
1616
17- const msgItem = { el, animationId : null }
18- msg . items . push ( msgItem )
19- const autoHide = el . getAttribute ( 'data-bb-autohide' ) === 'true' ;
17+ let msgItem = msg . items . find ( i => i . el . id === msgId )
18+ if ( msgItem === void 0 ) {
19+ msgItem = { el, animationId : null }
20+ msg . items . push ( msgItem )
21+ }
2022
23+ if ( msgItem . animationId ) {
24+ cancelAnimationFrame ( msgItem . animationId ) ;
25+ }
26+
27+ const autoHide = el . getAttribute ( 'data-bb-autohide' ) === 'true' ;
2128 if ( autoHide ) {
22- // auto close
2329 const delay = parseInt ( el . getAttribute ( 'data-bb-delay' ) ) ;
2430 let start = void 0
2531 const autoCloseAnimation = ts => {
@@ -45,10 +51,8 @@ export function show(id, msgId) {
4551 const hideHandler = setTimeout ( function ( ) {
4652 clearTimeout ( hideHandler ) ;
4753
48- // remove Id
4954 msg . items . pop ( ) ;
5055 if ( msg . items . length === 0 ) {
51- // call server method prepare remove dom
5256 msg . invoke . invokeMethodAsync ( msg . callback ) ;
5357 }
5458 } , 500 ) ;
@@ -58,9 +62,8 @@ export function show(id, msgId) {
5862 e . preventDefault ( ) ;
5963 e . stopPropagation ( ) ;
6064
61- // trigger on-dismiss event callback
6265 const alert = e . delegateTarget . closest ( '.alert' ) ;
63- if ( alert ) {
66+ if ( alert ) {
6467 const alertId = alert . getAttribute ( 'id' ) ;
6568 msg . invoke . invokeMethodAsync ( 'Dismiss' , alertId ) ;
6669 }
@@ -74,6 +77,7 @@ export function dispose(id) {
7477 msg . items . forEach ( item => {
7578 if ( item . animationId ) {
7679 cancelAnimationFrame ( item . animationId ) ;
80+ item . animationId = null ;
7781 }
7882 } ) ;
7983 }
0 commit comments