mirror of
https://github.com/openvk/openvk
synced 2024-12-23 09:01:15 +03:00
73a067a0c5
* rewrite * allow comments scroll * rework to up button * add posts scrolling function and ability to disabl * cloudflare bypass (do not uncomment)
35 lines
947 B
JavaScript
35 lines
947 B
JavaScript
window.addEventListener("scroll", function(e) {
|
|
if(window.scrollY < 100) {
|
|
if(window.temp_y_scroll) {
|
|
u('.toTop').addClass('has_down')
|
|
}
|
|
document.body.classList.toggle("scrolled", false);
|
|
} else {
|
|
document.body.classList.toggle("scrolled", true);
|
|
u('.toTop').removeClass('has_down')
|
|
}
|
|
});
|
|
|
|
u(".toTop").on("click", function(e) {
|
|
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')
|
|
})
|