1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-06-07 10:06:08 +02:00

notifications.js: prevent multiple hide timeouts from getting added.

This commit is contained in:
Kushagra Gour 2017-07-15 17:42:46 +05:30
parent abccf89b97
commit d6fc01dbbc

View File

@ -1,5 +1,6 @@
(function() {
var noticationContainerEL = $('#js-alerts-container');
const noticationContainerEL = $('#js-alerts-container');
var hideTimeout;
function addNotification(msg) {
// var n = document.createElement('div');
@ -8,7 +9,8 @@
noticationContainerEL.textContent = msg;
noticationContainerEL.classList.add('is-active');
setTimeout(function() {
clearTimeout(hideTimeout);
hideTimeout = setTimeout(function() {
noticationContainerEL.classList.remove('is-active');
}, 2000);
}