import anime from 'animejs/lib/anime.es.js'; const notifcation = document.getElementById('notifications'); const notify = document.getElementById('notifyMessage'); const messageText = document.getElementById('message-text'); const iconGood = document.getElementById('notify-good'); const iconLame = document.getElementById('notify-lame'); const iconWorking = document.getElementById('notify-working'); export default class Notfications { //-------------------------- // constructor //-------------------------- constructor() {} //-------------------------- // methods //-------------------------- alert(text, status) { notifcation.style.display = 'block'; iconWorking.style.display = 'none'; iconGood.style.display = 'none'; iconLame.style.display = 'none'; var color = ''; if (status !== null) { if (status) { color = '#32cd32'; iconWorking.style.display = 'none'; iconGood.style.display = 'block'; } else { color = '#F64747'; iconWorking.style.display = 'none'; iconLame.style.display = 'block'; } } else { color = '#200317'; iconWorking.style.display = 'block'; } notify.classList.remove('notify-close'); notify.classList.add('notify-open'); messageText.innerHTML = text; anime({ targets: messageText, backgroundColor: color, easing: 'easeInOutQuint', duration: 700, complete: () => { if (status !== null) { setTimeout(() => { notify.addEventListener('transitionend', () => { notifcation.style.display = 'none'; }); notify.classList.add('notify-close'); notify.classList.remove('notify-open'); }, 1000); } } }); /* anime({ targets: message, marginTop: '-20px', easing: 'easeInOutQuint', duration: 500, opacity: 1, complete: () => { setTimeout(() => { anime({ targets: message, marginTop: '-125px', easing: 'easeOutQuint', duration: 500, opacity: 0, complete: () => { notifcation.style.display = 'none'; } }); }, 1000); } }); */ } //-------------------------- // event handlers //-------------------------- }