mirror of
https://github.com/chinchang/web-maker.git
synced 2025-06-08 18:54:49 +02:00
notifications.js: prevent multiple hide timeouts from getting added.
This commit is contained in:
parent
abccf89b97
commit
d6fc01dbbc
@ -1,5 +1,6 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var noticationContainerEL = $('#js-alerts-container');
|
const noticationContainerEL = $('#js-alerts-container');
|
||||||
|
var hideTimeout;
|
||||||
|
|
||||||
function addNotification(msg) {
|
function addNotification(msg) {
|
||||||
// var n = document.createElement('div');
|
// var n = document.createElement('div');
|
||||||
@ -8,7 +9,8 @@
|
|||||||
noticationContainerEL.textContent = msg;
|
noticationContainerEL.textContent = msg;
|
||||||
noticationContainerEL.classList.add('is-active');
|
noticationContainerEL.classList.add('is-active');
|
||||||
|
|
||||||
setTimeout(function() {
|
clearTimeout(hideTimeout);
|
||||||
|
hideTimeout = setTimeout(function() {
|
||||||
noticationContainerEL.classList.remove('is-active');
|
noticationContainerEL.classList.remove('is-active');
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user