简体   繁体   English

使用jQuery平滑滚动

[英]Smooth scrolling with jquery

I know there are questions about smooth scrolling on SF already but I am unable to find what I want. 我知道已经有关于在SF上平滑滚动的问题,但是我找不到我想要的。 Already used improved smooth scroll script but it's the one on this website http://michaelacevedo.com I want to achieve. 已经使用了改进的平滑滚动脚本,但这是我要实现的此网站http://michaelacevedo.com上的脚本。 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 谢谢

$('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://matthewlein.com/experiments/easing.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM