【问题标题】:fullpage.js moveTo() functionfullpage.js moveTo() 函数
【发布时间】:2014-04-02 13:53:14
【问题描述】:

我正在尝试使用 fullpage.js 中的 moveTo() 函数,它允许我导航到特定的部分/幻灯片,如下所示:

/*Scrolling to the section with the anchor link `firstSlide` and to the 2nd Slide */
$.fn.fullpage.moveTo('firstSlide', 2);

我试图在afterSlideLoad() 函数中使用它,以尝试自动循环浏览幻灯片。我的代码如下所示:

 $.fn.fullpage({
     anchors: ['home', 'gallery'],
     afterSlideLoad: function(anchorLink, index, slideAnchor, slideIndex) {
         if (anchorLink == 'gallery') {
             if (slideIndex == 11) {
                  setTimeout(function() {
                      moveTo(2,0);
                  }, 1000);
             } else {
                  setTimeout(function() {
                      moveTo(2, slideIndex + 1);
                  }, 1000);
             }
         }
     });

这似乎没有做任何事情,我也尝试过moveTo('gallery', 1);

对我哪里出错有什么建议吗?

【问题讨论】:

    标签: javascript jquery fullpage.js


    【解决方案1】:

    正如documentation you are linking 中所指定的,该函数必须这样调用:

    $.fn.fullpage.moveTo('firstSlide', 2);
    

    不像你那样做:

    moveTo('firstSlide', 2);
    

    Live demo

    【讨论】:

    • 信不信由你,我想我也试过了,但我想我一定是这样称呼它的 $.fn.fullpage.moveTo(firstSlide, 2);谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多