Skip to content
This repository has been archived by the owner on Nov 25, 2021. It is now read-only.

Page skip and cancelled animation on page navigation multiple press #77

Closed
mcarreon opened this issue Oct 28, 2018 · 7 comments
Closed

Comments

@mcarreon
Copy link

Background

I have gotoNext() and gotoPrevious() as onClick events for buttons.

Issue

When either button is pressed multiple times before the animation completes on a unique page, the page index skips in the respective direction.

Effects

  • Page index skips
  • When moving backwards or forward, if clicked enough to reach past the end of the index, it loops back to the beginning.
    * This occurs even when looping is disabled
  • If the buttons are spamclicked the animation bugs out

Possible solution

If this is cause by the events being called multiple times before they can process, is there a way to disable further click events until completion of the animation after the function is called?

@darenju
Copy link
Owner

darenju commented Oct 29, 2018

Hello @mcarreon, you can use the onPageChange callback to re-enable your button. On click, use a state entry that holds either the button can be clicked (e.g. canClick), set it to false, and assign your disabled prop on button accordingly (!canClick). On the onPageChange callback, re-enable the button by setting canClick state member to true.

@mcarreon
Copy link
Author

mcarreon commented Oct 29, 2018 via email

@darenju
Copy link
Owner

darenju commented Oct 29, 2018

@mcarreon Just put it in an actual button tag, it's better for UX anyway.

But I agree there should be a state property inside the FlipPage component that says if you can move or not. Going to work on that.

@darenju
Copy link
Owner

darenju commented Oct 29, 2018

I made a fix for this in v1.2.2. @mcarreon Care to check out?

@mcarreon
Copy link
Author

I haven't converted them to buttons yet, will do that soon, thanks for the suggestion.

I tried it out, the issue still seems to happen. Is there a way to block the page index changing on method spam? The pages are double incrementing on double click

I think the animation bug might be due to these lines in index.jsx, as the animation seems to cancel on a second method press.

    const gotoPreviousPage = (e) => {
      this.stopMoving(e);
      this.gotoPreviousPage();
    };
    const gotoNextPage = (e) => {
      this.stopMoving(e);
      this.gotoNextPage();
    };

I'll be working on it, I'll let you know if I figure out anything

@darenju
Copy link
Owner

darenju commented Oct 30, 2018

So, has the behavior actually changed? Is there any evolution from what was done before?

The index shouldn't even change before the previous animation has completed.

@mcarreon
Copy link
Author

Visually the behavior is the same as before, I did see the added canAnimate state toggle from true to false.
It seemed like the index changed after the animation completed, but the spammed increments still went through

@darenju darenju closed this as completed Jun 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants