contact
This commit is contained in:
27
bib-toaster/toaster.js
Normal file
27
bib-toaster/toaster.js
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const toast = document.getElementById('flashToast');
|
||||
if (!toast) return;
|
||||
|
||||
// Show it
|
||||
requestAnimationFrame(() => {
|
||||
toast.classList.add('show');
|
||||
});
|
||||
|
||||
// Close on [×]
|
||||
toast.querySelector('.toast__close').addEventListener('click', () => {
|
||||
hideToast();
|
||||
});
|
||||
|
||||
// Auto-hide after 3s
|
||||
const hideTimeout = setTimeout(hideToast, 3000);
|
||||
|
||||
function hideToast(){
|
||||
clearTimeout(hideTimeout);
|
||||
toast.classList.add('hide');
|
||||
// Remove from DOM after transition
|
||||
toast.addEventListener('transitionend', () => {
|
||||
toast.remove();
|
||||
}, { once: true });
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user