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?
You 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.com";
}
}
...
});
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With