admin管理员组文章数量:1326662
Im using fullpage plugin in my website, this is my markup
<div id="fullpage">
<div class="section section1">Some section</div>
<div class="section section2">Some section</div>
<div class="section section3">Some section</div>
<div class="section section4">Last section</div>
</div>
In my website I want to do the following: User will scroll down section per section, when user reaches the last section I want to redirect the user to another page, how can I check that user is in last section in fullpage.js?
Im using fullpage plugin in my website, this is my markup
<div id="fullpage">
<div class="section section1">Some section</div>
<div class="section section2">Some section</div>
<div class="section section3">Some section</div>
<div class="section section4">Last section</div>
</div>
In my website I want to do the following: User will scroll down section per section, when user reaches the last section I want to redirect the user to another page, how can I check that user is in last section in fullpage.js?
Share Improve this question asked Aug 18, 2015 at 2:55 svelandiagsvelandiag 4,3201 gold badge42 silver badges80 bronze badges 1-
2
probably use
.afterLoad(anchorLink, index)
callback, and check if this receivedindex
parameter is equal to the length of$('#fullpage .section').length
. – Tahir Ahmed Commented Aug 18, 2015 at 3:02
2 Answers
Reset to default 5You can use the afterLoad
function in fullpage to achieve this. The following code snippet should give you an idea of how you can use afterLoad
to check if the user is on the last section and do a redirect if so:
$('#fullpage').fullpage({
...
afterLoad: function(anchorLink, index){
// Section indexes in fullpage start at 1
if(index === $('#fullpage .section').length){
window.location.href = "http://stackoverflow.";
}
}
...
});
Hi I finally figured out, I checked the fullpage has some callbacks, so I used the onLeave
callback, here is my code (in CoffeeScript)
$('#fullpage').fullpage
onLeave: (index, nextIndex, direction) ->
if index is 3 && direction is'down'
#redirect the user to a new page.
本文标签: javascriptCheck if it is last section fullPagejsStack Overflow
版权声明:本文标题:javascript - Check if it is last section fullPage.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742202476a2432218.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论