openvk/Web/static/js/scroll.js
Maxim Leshchenko d87277e7e7
Global: Fix up button
Due to the fact that "document.body.scrollTop" was removed from newer browsers, hovering over this button was not displayed. I replaced this with "window.scrollY" which works in newer browsers. I also localized the text on it.
2022-01-30 14:18:39 +02:00

14 lines
No EOL
334 B
JavaScript

window.addEventListener("scroll", function(e) {
if(window.scrollY < 100) {
document.body.classList.toggle("scrolled", false);
} else {
document.body.classList.toggle("scrolled", true);
}
});
u(".toTop").on("click", function(e) {
window.scrollTo({
top: 0,
behavior: "smooth"
});
});