Smooth scrolling with jquery

ぐ巨炮叔叔 提交于 2019-12-13 21:37:30

问题


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


回答1:


$('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



来源:https://stackoverflow.com/questions/35722835/smooth-scrolling-with-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!