heroweb/poc/in/assets/js/toast.js

22 lines
732 B
JavaScript
Raw Normal View History

2024-09-02 05:28:06 +00:00
var triggers = document.querySelectorAll("[toast]");
triggers.forEach((trigger) => {
let toastId = trigger.getAttribute("data-target");
trigger.addEventListener("click", function () {
let toast = document.querySelector("#" + toastId);
if (trigger.getAttribute("aria-hidden") == "true") {
trigger.setAttribute("aria-hidden", "false");
toast.classList.remove("hidden");
setTimeout(function () {
toast.classList.remove("opacity-0");
}, 100);
setTimeout(function () {
trigger.setAttribute("aria-hidden", "true");
toast.classList.add("opacity-0");
setTimeout(function () {
toast.classList.add("hidden");
}, 200);
}, 3800);
}
});
});