shiloh-echo/js/back-to-top.js
Tony M 9de5c64704 Drop jQuery, rewrite JS in vanilla, defer scripts
Remove jquery-3.7.1.min.js (162 KB) and countdown.js plugin.
Rewrite main.js, back-to-top.js, agenda.js in vanilla JS.
Replace jQuery countdown init with inline vanilla countdown.
2026-07-04 11:33:25 -07:00

25 lines
667 B
JavaScript

document.addEventListener("DOMContentLoaded", function () {
var bar = document.getElementById("sticky-bar");
var btn = document.getElementById("back-to-top");
if (!bar || !btn) return;
window.addEventListener("scroll", function () {
var y = window.pageYOffset || document.documentElement.scrollTop;
if (y > 600) {
bar.classList.add("is-visible");
} else {
bar.classList.remove("is-visible");
}
if (y > 100) {
btn.classList.add("is-visible");
} else {
btn.classList.remove("is-visible");
}
});
btn.addEventListener("click", function () {
window.scrollTo({ top: 0, behavior: "smooth" });
});
});