我正在创建一个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
对我做错的任何提示?
不需要通过OnLeave / silentMoveTo这样做,只需将active
类添加到我想要显示的幻灯片中。