toast should allow prevent default for hide and show events

This commit is contained in:
Johann-S 2019-05-16 11:57:05 +02:00
parent 4ea7e11233
commit d5752a18ab
2 changed files with 81 additions and 2 deletions

View file

@ -90,7 +90,11 @@ class Toast {
// Public
show() {
EventHandler.trigger(this._element, Event.SHOW)
const showEvent = EventHandler.trigger(this._element, Event.SHOW)
if (showEvent.defaultPrevented) {
return
}
if (this._config.animation) {
this._element.classList.add(ClassName.FADE)
@ -126,7 +130,11 @@ class Toast {
return
}
EventHandler.trigger(this._element, Event.HIDE)
const hideEvent = EventHandler.trigger(this._element, Event.HIDE)
if (hideEvent.defaultPrevented) {
return
}
const complete = () => {
this._element.classList.add(ClassName.HIDE)