我已经设置了fullpage.js,但是我希望能够滚动到一个部分,如果满足了某些条件,就可以在下一个滚动的同一节中显示新的元素。下一卷不应该继续到下一节。
使用回调,我能够确定节何时需要第二个卷轴。从文档中,我甚至能够在滚动发生之前取消它,因此允许显示新的元素,而无需进入下一节。问题是允许它转到后面的下一节。我要么让它停止滚动,但不再能够再次滚动,或者文本在滚动到下一个部分时出现,因为任何类型的标志都可能更改,并且在下一个滚动页上触发多次,因此它会立即离开该部分。
//HTML - typical fullpage.js section
<div class="section">
<div>
<h1>Default Text</h1>
<p class="hidden-text">Additonal text to appear on second scroll</p>
</div>
</div>
<div class="section">
<div>
<h1>Next Section</h1>
</div>
</div>
//fullpage.js - the callbacks being used
afterLoad: function(anchorLink, index){
preventScroll = false;
if(this.has(".hidden-text").length){
preventScroll = true;
}
},
onLeave: function(index, nextIndex, direction){
if (preventScroll && direction == "down") {
this.find('.hidden-text').addClass('animate-text');
this.find('.hidden-text').removeClass('hidden-text');
return false;
}
},在这里发现:http://codepen.io/anon/pen/oxEexY
发布于 2016-04-11 14:12:34
您必须添加逻辑才能知道隐藏文本何时显示。添加一个timeOut或什么的。当发生这种情况时,将标志preventScroll更改为true。
在这种情况下,我假设文本显示在1秒(1000毫秒)之后:
在线复制
另外,请注意我是如何使用$(this)而不是this的。
https://stackoverflow.com/questions/36505728
复制相似问题