Hide scroll to top button when the scrolling stops

Dear Stefan

This is very problematic for me to have the scroll to the
the top button on the page all the time.

What is the code that I can use to hide it?

It’s like the navbar but the opposite

When scrolling stops it will disappear because right now it is on other elements like buttons that I need to be visible.



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) {

    // 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); 
1 Like

Hi Stefan

Works perfectly!

Thanks maestro :kissing_heart: :purple_heart: