Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: beforeLeave() and cancelMove() #1262

Closed
russellbrown opened this issue May 29, 2015 · 2 comments
Closed

Feature request: beforeLeave() and cancelMove() #1262

russellbrown opened this issue May 29, 2015 · 2 comments

Comments

@russellbrown
Copy link

It would be really great if there was a way to hook into a beforeLeave(index, nextIndex, direction) callback and halt the normal movement between sections with a cancelMove() method.

This is because in some cases I don't want the next scroll/swipe to move to the next section but to trigger something else within the current section instead, like an animation or something. For example:

...
<section>
  <p>This paragraph appears from the start</p>
  <p class="hidden">This one fades in with the next swipe</p>
</section>
...
$('#fullpage').fullpage({
  beforeLeave: function(index, nextIndex, direction){
    var leavingSection = $('#fullpage section').eq(index-1);
    if (leavingSection.find("p.hidden").length > 0) {
      $.fn.fullpage.cancelMove();
      leavingSection.find("p.hidden").removeClass("hidden");
    }
  }
});
@alvarotrigo
Copy link
Owner

Related with this pull request.

It will be added in the next release.

Returning false in the onLeave and onSlideLeave callbacks will cancel the move.

@russellbrown
Copy link
Author

Awesome thanks, I'll keep my eyes open for that. Really great plugin by the way, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants