Search code examples
javascriptjqueryanimationscrollanchor-scroll

Smooth scrolling with jquery


I know there are questions about smooth scrolling on SF already but I am unable to find what I want. Already used improved smooth scroll script but it's the one on this website http://michaelacevedo.com I want to achieve. When you click on a link then it starts off real slow and then speedy animation takes you to the desired section. It's really different than other smooth scrolls. Can anyone help implement this effect and explain what's the code doing. Thanks


Solution

  • $('a').click(function(){
        var top = $('body').find($(this).attr('href')).offset().top;
        $('html, body').animate({
            scrollTop: top
        },500, 'easeOutExpo');
    
        return false;
    });
    

    Then select the easing you want https://matthewlein.com/experiments/easing.html