Files
Orient_Website/bib-toaster/toaster.js
2025-08-11 16:38:01 +05:45

28 lines
644 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 });
}
});