【问题标题】:How to adjust speed of smoothScroll如何调整smoothScroll的速度
【发布时间】:2015-12-08 11:39:29
【问题描述】:

我目前在水平滚动网站上使用smoothScroll 功能。我正在运行的当前 jQuery 既适用于上一个/下一个部分按钮,也适用于所有部分的常规导航。常规导航是 .scroll-test 类。这是 jQuery 代码:

$(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();
});

我想要的是改变滚动动画的速度。现在,当跳过一页以上时,它的速度非常快。

提前致谢!

【问题讨论】:

    标签: javascript jquery smooth-scrolling


    【解决方案1】:

    你不能像这样通过将参数(对象)传递给函数来设置速度

    .smoothScroll({speed:2000})
    

    速度值是以毫秒为单位的动画时间

    【讨论】:

    • 工作就像一个魅力!非常感谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-13
    • 2021-06-25
    • 1970-01-01
    • 2022-09-24
    相关资源
    最近更新 更多