使用jQuery平滑滚动 [英] Smooth scrolling with jquery

查看:138
本文介绍了使用jQuery平滑滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道已经有关于在SF上平滑滚动的问题,但是我找不到我想要的东西.我已经使用了经过改进的平滑滚动脚本,但这是该网站上的我想要实现的脚本. http://michaelacevedo.com .当您单击链接时,它会从真正的慢开始,然后快速的动画将您带到所需的部分.确实与其他平滑卷轴不同.任何人都可以帮助实现这种效果并解释代码的功能. 谢谢

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

推荐答案

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

    return false;
});

然后选择您想要的缓动 https://matthewlein.com/experiments/easing.html

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

这篇关于使用jQuery平滑滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆