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

Added a delay property to the Transition component #340

Closed
wants to merge 1 commit into from

Conversation

taabooone
Copy link

@taabooone taabooone commented May 21, 2018

Added a delay property to the transition component.

use case: I want to stagger the appearing/entering/exiting of components.

usage:

{ objects.map(( obj, idx ) => (
   <Transition delay={{ 
      enter: 200 * idx,
      exit: 100 * idx, 
    }} 
   >
      {obj}
   </Transition>
))}

@jquense
Copy link
Collaborator

jquense commented May 21, 2018

hey there thanks for the PR. We've talked a bit about adding this in the past (see #78) and I believe the conclusion was that this sort of thing is better left to higher level implementations of Transition, since delays are often builtin to the animation strategy (transition or animation for instance in css). This makes it hard to successfully integrate a timeout based delay with css transitions, because of timer drift and other js implementation details.

I guess the TL; DR; on this is if you are using CSSTransition this is already possible with the native delay properties.

@silvenon
Copy link
Collaborator

@taabooone do you think there's a benefit to adding the delay prop in comparison to modifying the value of the timeout prop by adding the delay?

@taabooone
Copy link
Author

@silvenon The timeout prop does not directly cause a delay on the animation to happen. It will just increase the time from Entering -> Entering-done when using CSSTransition. The reason I went for a delay is to stagger the transition when I was adding a ton of elements at once.

@silvenon
Copy link
Collaborator

Staggering is indeed a common animation practice, but also mainly eye-candy.

In my opinion the main reason why react-transition-group is so useful is because it can animate the existence of a component in the DOM, which is something that CSS transitions can't do. In that context having a delay feature might be confusing because then the question becomes "why don't we just change the in prop later?".

In other words, I can't imagine a scenario where you would want to add a bunch of components to the DOM at slightly different times, that would be bad for performance, but I can imagine one where you want to make it look that way, which is outside the scope of this library. Would a library like react-motion be a better fit for your desired effect?

In any case, thanks a lot for your effort. 🏆 In the future, before implementing new features you can search if there was an existing proposal, and if there isn't, open an issue first to start a discussion. 😉

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.

3 participants