1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-10-03 16:51:54 +02:00
Toast should allow prevent default for hide and show events
This commit is contained in:
Johann-S
2019-05-22 09:55:14 +02:00
committed by XhmikosR
parent fe777292b5
commit c6dd1a7d93
2 changed files with 84 additions and 2 deletions

View File

@@ -82,7 +82,12 @@ class Toast {
// Public
show() {
$(this._element).trigger(Event.SHOW)
const showEvent = $.Event(Event.SHOW)
$(this._element).trigger(showEvent)
if (showEvent.isDefaultPrevented()) {
return
}
if (this._config.animation) {
this._element.classList.add(ClassName.FADE)
@@ -119,7 +124,13 @@ class Toast {
return
}
$(this._element).trigger(Event.HIDE)
const hideEvent = $.Event(Event.HIDE)
$(this._element).trigger(hideEvent)
if (hideEvent.isDefaultPrevented()) {
return
}
this._close()
}