Notice with Event Listeners
Notice to Error to Success to Info
window.fakeLoad = function fakeLoad() {
let curValue = 1;
let progress;
// Make a loader.
const notice = PNotify.notice({
title: 'Creating series of tubes',
text: '
\n' +
'
' +
'div>\n' +
'' +
'div>',
textTrusted: true,
icon: 'fas fa-cog fa-spin',
hide: false,
destroy: true,
closer: false,
sticker: false
});
notice.on('pnotify:afterOpen', () => {
progress = notice.refs.elem.querySelector(
'.progress-bar');
progress.style.width = curValue + '%';
progress.attributes['aria-valuenow'].value = curValue;
// Pretend to do something.
let plus = 1;
const timer = setInterval(() => {
if (curValue === 70) {
plus = 0.25;
notice.update({
title: 'Aligning discrete worms',
icon: 'fas fa-circle-notch fa-spin'
});
}
if (curValue === 80) {
notice.update({
title: 'Connecting end points',
icon: 'fas fa-sync fa-spin'
});
}
if (curValue === 90) {
notice.update({
title: 'Dividing and conquering',
icon: 'fas fa-spinner fa-pulse'
});
}
if (curValue >= 100) {
// Clean up the interval.
window.clearInterval(timer);
notice.close();
return;
}
curValue += plus;
progress.style.width = curValue + '%';
progress.attributes['aria-valuenow'].value =
curValue;
}, 65);
});
};
Progress Loader