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

Add set timeout fallback #1

Merged
merged 3 commits into from
Sep 6, 2023
Merged

Conversation

nigelgutzmann
Copy link

FlipMove relies on the transitionend event to know when a transition has ended, and thus call the onFinish and onFinishAll callbacks. However, in some cases, the transitionend event doesn't fire. This means that FlipMove gets into a broken state, where remainingAnimations never goes back to 0. Thus an animation will never fully complete, and FlipMove will entirely stop working.

I believe this happens when the list or element components are re-rendered really fast, and FlipMove doesn't do quite the correct reconciling to know which elements are mid-transition.

To solve this, I am taking a page out of react-bootstrap's playbook, and using setTimeout as a fallback to make sure that the transitionend event is definitely fired.

https://github.dev/react-bootstrap/dom-helpers

@nigelgutzmann nigelgutzmann merged commit 73f355b into master Sep 6, 2023
@nigelgutzmann nigelgutzmann deleted the add-setTimeout-fallback branch September 6, 2023 22:48
@nigelgutzmann
Copy link
Author

Note: react-flip-move has discussed this approach, and has decided not to implement it: joshwcomeau#120 (comment)

I think they wanted to find the root issue leading to this bug. But that was several years ago already, and they haven't fixed it there. So for now, we can just fix it here.

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

Successfully merging this pull request may close these issues.

1 participant