javascript - How to adjust speed of smoothScroll - Stack Overflow

I am currently using the smoothScroll function on a horizontally scrolling website. The current jQuery

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 badges
Add a ment  | 

1 Answer 1

Reset to default 5

Can'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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745672700a4639502.html

相关推荐

  • javascript - How to adjust speed of smoothScroll - Stack Overflow

    I am currently using the smoothScroll function on a horizontally scrolling website. The current jQuery

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信