fullpage.js silentMoveTo似乎不起作用?

时间:2019-03-05 10:34:42

标签: javascript fullpage.js

我正在创建一个fullpage.js网站,我需要在其中滚动幻灯片以查看特定的幻灯片。像这样:

1
X2X
3
4

在X2X是3张幻灯片的情况下,我想降落在第二张幻灯片上,以便用户可以向左或向右滑动。

我正在使用OnLeave来呼叫silentMoveTo,但是我所做的一切似乎都没有效果:

onLeave: function(origin, destination, direction) {
        var params = {
            origin: origin,
            destination: destination,
            direction: direction
        };
        //after leaving first section
        console.log("leaving...");
        if (origin.index == 0 && direction == "down") {
        // moves the slides to the 2nd slide
        console.log("fire after 1?");
        fullpage_api.silentMoveTo(1, 1);
        }
    }

但是silentMoveTo不起作用。这是一个CodePen https://codepen.io/thetwopct/pen/bZwyRw

有什么提示我做错了吗?

1 个答案:

答案 0 :(得分:1)

不需要通过OnLeave / silentMoveTo进行此操作,只需将active类添加到我要显示的幻灯片中即可。

根据https://github.com/alvarotrigo/fullPage.js/issues/522