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

Accommodate interruption of transitions in ReactTransitionGroup #5989

Closed
wants to merge 1 commit into from
Closed

Accommodate interruption of transitions in ReactTransitionGroup #5989

wants to merge 1 commit into from

Conversation

abutterworth
Copy link

Updated the way ReactTransitionGroup manages children and triggers animation events in order to allow for interruption of transitions. Now the TransitionGroup will not wait for didEnter callbacks in order to trigger willLeave.

This does not change the behavior of CSSTransitionGroups because it uses timeouts.

…mation events in order to allow for interruption of transitions. The ReactTransitionGroup test now tests for this behavior. CSSTransition group was updated to expect children to be appended rather than prepended.
@gaearon
Copy link
Collaborator

gaearon commented Mar 27, 2016

Can you help me understand how this compares to #5028? Thanks!

@abutterworth
Copy link
Author

They address the same issue. #5028 addresses the issue by making minimal changes to the implementation of ReactTransitionGroup, while this PR rethinks it somewhat.

The goal here was to avoid managing a list of transitions and instead create an object to represent the actual state of the children for comparison with the declared props.children. IMO this is a simpler solution, but I could understand the desire to change as little as possible.

As far as how they relate to #5575: I don't think either address that issue which, if I'm understanding correctly, has to do more with the order in which multiple components are added or removed.

Both this and #5028 address an issue like this: Given a toggle button that adds or removes a child from a ReactTransitionGroup. Let's say the transition takes 1 second to complete. In React currently, if you click the toggle button once to add the child and then again very quickly the child will complete its 1 second transition in and after it's finished begin its 1 second transition out. This approach, would start the transition out immediately after the second toggle click. I can add a demo if that needs illustration.

This isn't a bug fix. But I think it's an improvement upon the current behavior which has proved frustrating when trying to make fast responding UIs.

As far as whether this is a breaking change, I'm not sure. The current TransitionGroup will always call componentDidEnter if it calls componentWillEnter. With these changes, that is not guaranteed since you can effectively cancel an enter transition. So if a component started some process or set a timeout at willEnter that relies upon a didEnter callback to properly clean up, there would likely be issues.

@gaearon
Copy link
Collaborator

gaearon commented Jun 26, 2016

We don’t have an owner for ReactTransitionGroup internally because we don’t use it, and it seems like we don’t have the capacity to review PRs for it at the moment. Your best strategy might be to fork its code (or find an existing fork) and propose these changes there. If any of the forks turns out to be successful we might deprecate our own version and start pointing to the fork in the docs. Sorry it turned out to be this way, but it’s best to do something than to leave this hang forever so I’m closing.

@gaearon gaearon closed this Jun 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants