📢 This forum is no longer actively updated, but we've kept it online as a resource — there's a lot of helpful history here! For new discussions, come join us on
discord!
You need to do exactly the same what you did on video from post above, just use code below instead, and you need to set class on that button “scroll-to-top”.
let isScrolling;
$(window).on('scroll', function() {
if (isScrolling) {
clearTimeout(isScrolling);
}
// Show the button while scrolling
$('.scroll-to-top').css("opacity", "1");
$('.scroll-to-top').css("pointer-events", "auto");
// Set a timer to hide the button after 300ms of no scrolling
isScrolling = setTimeout(function() {
$('.scroll-to-top').css("opacity", "0");
$('.scroll-to-top').css("pointer-events", "none");
}, 300);
});