Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions js/src/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ const Event = {
}

const ClassName = {
FADE : 'fade',
HIDE : 'hide',
SHOW : 'show'
FADE : 'fade',
HIDE : 'hide',
SHOW : 'show',
SHOWING : 'showing'
}

const DefaultType = {
Expand Down Expand Up @@ -84,14 +85,18 @@ class Toast {
}

const complete = () => {
this._element.classList.remove(ClassName.SHOWING)
this._element.classList.add(ClassName.SHOW)

$(this._element).trigger(Event.SHOWN)

if (this._config.autohide) {
this.hide()
}
}

this._element.classList.add(ClassName.SHOW)
this._element.classList.remove(ClassName.HIDE)
this._element.classList.add(ClassName.SHOWING)
if (this._config.animation) {
const transitionDuration = Util.getTransitionDurationFromElement(this._element)

Expand Down Expand Up @@ -162,11 +167,11 @@ class Toast {

_close() {
const complete = () => {
this._element.classList.add(ClassName.HIDE)
$(this._element).trigger(Event.HIDDEN)
}

this._element.classList.remove(ClassName.SHOW)

if (this._config.animation) {
const transitionDuration = Util.getTransitionDurationFromElement(this._element)

Expand Down
11 changes: 10 additions & 1 deletion scss/_toasts.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.toast {
display: none;
max-width: $toast-max-width;
overflow: hidden; // cheap rounded corners on nested items
font-size: $toast-font-size; // knock it down to 14px
Expand All @@ -9,13 +8,23 @@
border-radius: $toast-border-radius;
box-shadow: $toast-box-shadow;
backdrop-filter: blur(10px);
opacity: 0;

+ .toast {
margin-top: $toast-padding-x;
}

&.showing {
opacity: 1;
}

&.show {
display: block;
opacity: 1;
}

&.hide {
display: none;
}
}

Expand Down