admin管理员组文章数量:1435859
I am currently using the smoothScroll
function on a horizontally scrolling website. The current jQuery I have running is both for a previous/next section button and a regular navigation for all sections. The regular navigation is that with the .scroll-test class. This is the jQuery code:
$(document).ready(function() {
var url = 1;
$('a.forward').click(function () {
url = url + 1;
$(this).attr({ href: '#section' + url });
$(this).parent().attr({ class: 'section' + url });
});
$('a.backward').click(function () {
url = url - 1;
$(this).attr({ href: '#section' + url });
$(this).parent().attr({ class: 'section' + url });
});
$('a.forward, a.backward').smoothScroll();
$('a.scroll-test').smoothScroll();
});
What I want is to change the speed of the scroll animation. Right now it's going really fast when jumping over more than one page.
Thanks in advance!
I am currently using the smoothScroll
function on a horizontally scrolling website. The current jQuery I have running is both for a previous/next section button and a regular navigation for all sections. The regular navigation is that with the .scroll-test class. This is the jQuery code:
$(document).ready(function() {
var url = 1;
$('a.forward').click(function () {
url = url + 1;
$(this).attr({ href: '#section' + url });
$(this).parent().attr({ class: 'section' + url });
});
$('a.backward').click(function () {
url = url - 1;
$(this).attr({ href: '#section' + url });
$(this).parent().attr({ class: 'section' + url });
});
$('a.forward, a.backward').smoothScroll();
$('a.scroll-test').smoothScroll();
});
What I want is to change the speed of the scroll animation. Right now it's going really fast when jumping over more than one page.
Thanks in advance!
Share Improve this question edited Dec 8, 2015 at 11:41 Rory McCrossan 338k41 gold badges320 silver badges351 bronze badges asked Dec 8, 2015 at 11:39 Emil ØstervigEmil Østervig 4606 silver badges21 bronze badges1 Answer
Reset to default 5Can't you set the speed by passing it a param (object) to the function like so
.smoothScroll({speed:2000})
The speed value is the animation time in milliseconds
本文标签: javascriptHow to adjust speed of smoothScrollStack Overflow
版权声明:本文标题:javascript - How to adjust speed of smoothScroll - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745672699a2669667.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论