Skip to content

Commit 84fbc9c

Browse files
committed
Update toast plugin.
1 parent 3f41dc4 commit 84fbc9c

2 files changed

Lines changed: 15 additions & 21 deletions

File tree

public/css/toast.css

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,7 @@ html[data-bs-theme=dark] .toast-plugin .progress-bar.bg-dark {
101101
}
102102

103103
.toast-plugin .progress-bar {
104-
animation-name: toast-plugin-progress;
105-
}
106-
107-
@keyframes toast-plugin-progress {
108-
0% {
109-
width: 0
110-
}
111-
112-
100% {
113-
width: 100%
114-
}
104+
width: 0;
115105
}
116106

117107
/* margins */

public/js/plugins/plugin-toast.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@
414414
/**
415415
* Append the header subtitle.
416416
417-
* @param {jQuery|any} $parent - the parent to append header subtitle to.
417+
* @param {jQuery|any} $parent - the parent to append the header subtitle to.
418418
* @param {Object} options - The toast options.
419419
* @private
420420
*/
@@ -430,7 +430,7 @@
430430
/**
431431
* Append the header close button.
432432
*
433-
* @param {jQuery|any} $parent - the parent to append close button to.
433+
* @param {jQuery|any} $parent - the parent to append the close button to.
434434
* @param {Object} options - The toast options.
435435
* @private
436436
*/
@@ -457,7 +457,7 @@
457457
/**
458458
* Append the header title.
459459
*
460-
* @param {jQuery|any} $parent - the parent to append header title to.
460+
* @param {jQuery|any} $parent - the parent to append the header title to.
461461
* @param {Object} options - The toast options.
462462
* @private
463463
*/
@@ -515,7 +515,7 @@
515515
/**
516516
* Append the bottom progress bar.
517517
*
518-
* @param {jQuery|any} $parent - the parent to append progress bar to.
518+
* @param {jQuery|any} $parent - the parent to append the progress bar to.
519519
* @param {Object} options - The toast options.
520520
* @private
521521
*/
@@ -526,9 +526,9 @@
526526
const $bar = $('<div/>', {
527527
class: `progress-bar overflow-hidden bg-${options.type}`,
528528
role: 'progressbar',
529-
'aria-valuenow': '0',
530529
'aria-valuemin': '0',
531-
'aria-valuemax': '100'
530+
'aria-valuemax': '100',
531+
'aria-valuenow': '100'
532532
});
533533
const $progress = $('<div/>', {
534534
class: 'progress bg-transparent rounded-0',
@@ -543,18 +543,22 @@
543543
/**
544544
* Show the toast.
545545
*
546-
* @param {jQuery|any} $toast - The toast to show.
546+
* @param {jQuery<HTMLDivElement>} $toast - The toast to show.
547547
* @param {Object} options - The toast options.
548548
* @return {Toaster} This instance.
549549
* @private
550550
*/
551551
_showToast: function ($toast, options) {
552-
const that = this;
553552
if (options.progress && options.timeout > 200) {
554553
const $progress = $toast.find('.progress-bar');
555554
if ($progress.length) {
556555
$toast.on('shown.bs.toast', function () {
557-
$progress.css('animation-duration', `${options.timeout}ms`);
556+
setTimeout(() => {
557+
$progress.css({
558+
transitionDuration: `${options.timeout}ms`,
559+
width: '100%'
560+
});
561+
}, 10);
558562
});
559563
}
560564
}
@@ -568,7 +572,7 @@
568572
}
569573
}).toast('show');
570574

571-
return that;
575+
return this;
572576
},
573577

574578
/**

0 commit comments

Comments
 (0)