首页 > 解决方案 > fullpage.js silentMoveTo 似乎不起作用?

问题描述

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

  1
X2X
  3
  4

X2X 是 3 张幻灯片,我想降落在第 2 张幻灯片上,以便用户可以向左或向右。

我习惯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

关于我做错了什么的任何提示?

标签: javascriptfullpage.js

解决方案


不需要通过 OnLeave/silentMoveTo 执行此操作,只需active向我要展示的幻灯片添加类即可。

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


推荐阅读