2020-06-07 19:04:43 +03:00
|
|
|
window.addEventListener("scroll", function(e) {
|
2022-01-30 15:18:39 +03:00
|
|
|
if(window.scrollY < 100) {
|
2024-11-22 16:31:07 +03:00
|
|
|
if(window.temp_y_scroll) {
|
|
|
|
u('.toTop').addClass('has_down')
|
|
|
|
}
|
2020-06-07 19:04:43 +03:00
|
|
|
document.body.classList.toggle("scrolled", false);
|
|
|
|
} else {
|
|
|
|
document.body.classList.toggle("scrolled", true);
|
2024-11-22 16:31:07 +03:00
|
|
|
u('.toTop').removeClass('has_down')
|
2020-06-07 19:04:43 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
u(".toTop").on("click", function(e) {
|
2024-11-22 16:31:07 +03:00
|
|
|
const y_scroll = window.scrollY
|
|
|
|
const scroll_margin = 20
|
|
|
|
|
|
|
|
if(y_scroll > 100) {
|
|
|
|
window.temp_y_scroll = y_scroll
|
|
|
|
window.scrollTo(0, scroll_margin)
|
|
|
|
window.scrollTo({
|
|
|
|
top: 0,
|
|
|
|
behavior: "smooth"
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
if(window.temp_y_scroll) {
|
|
|
|
window.scrollTo(0, window.temp_y_scroll - scroll_margin)
|
|
|
|
window.scrollTo({
|
|
|
|
top: window.temp_y_scroll,
|
|
|
|
behavior: "smooth"
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u(document).trigger('scroll')
|
|
|
|
})
|