Files
shop-pip/app/static/js/main.js
T

40 lines
1.1 KiB
JavaScript

(() => {
const toast = document.getElementById("toast");
let toastTimer;
const showToast = (message) => {
if (!toast) return;
toast.hidden = false;
toast.textContent = message;
clearTimeout(toastTimer);
toastTimer = setTimeout(() => {
toast.hidden = true;
}, 2600);
};
document.querySelectorAll("[data-buy]").forEach((button) => {
button.addEventListener("click", () => {
const slug = button.getAttribute("data-buy");
showToast(${slug}» — оплата скоро будет подключена`);
});
});
const reveals = document.querySelectorAll(".reveal");
if ("IntersectionObserver" in window) {
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("is-visible");
observer.unobserve(entry.target);
}
});
},
{ threshold: 0.15 }
);
reveals.forEach((el) => observer.observe(el));
} else {
reveals.forEach((el) => el.classList.add("is-visible"));
}
})();