-
Notifications
You must be signed in to change notification settings - Fork 651
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
Staggered / Sequential Transitions #78
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this, I think we probably need to think a bit more on the potential API here. See my note inline with the code
src/TransitionGroup.js
Outdated
const { staggerTime } = this.props; | ||
const onExited = () => this.handleExited(child.key); | ||
const style = staggerTime > 0 ? { | ||
transitionDelay: `${staggerTime * (index + 1)}ms` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't go here, since it's css specific and this component is intended to be a generic component. I believe you should actually be able to implement this with the API as it is with minimal fuss. Your Transition children can accept a 'delay' property, and either compute it your as you map over the children or wrap TransitionGroup to inject it with similar logic.
<TransitionGroup>
{items.map((item, idx) =>
<StaggeredFade delay={staggerItem * (idx + 1)}>{item}</StaggeredFade>
)}
</TransitionGroup>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see your point. I'll see if I can re-work this without CSS. Thanks for the quick response.
@jquense I've retooled the PR as follows, which should support several scenarios. The The The difference between a staggered / sequential animation has little difference with this API. To get a sequential animation over a staggered one, one would pass down a Storybook ExamplesStaggered AnimationsSequential AnimationsSingle Delayed Animation |
Also some examples on what this may look like in action: Example Usage
|
@jquense any update on this? The API seems sound to me, but let me know if there are any remaining questions / work to be done on this. |
Hey there 👋 I appreciate the work you've put in here. My major concern is that this adds a lot of complexity to already complex components. I'm also uncomfortable with the bluring of some component boundaries. For instance My original thought was to try and implement this on top of the current current. e.g. wrap the components as they are so we don't need to make changes to the library here. I'd still like to try that approach before adding more code here, since these are already very delicate state machines. |
(off-topic but I want to spread Array.from) Replace |
This seems like a really useful addition. |
Had some downtime and revived this PR. Going to fix the implementation to at least keep the conversation open about adding staggered transition support to |
I would love to see this added. |
I would also like to see this added. |
Hey folks, My original comments still stand. I don't think that TransitionGroup or Transition are the correct places to add this sort of functionality. Animation delays are almost always the sort of thing you want to handle directly next to and with the animation itself. For instance with CSS transitions are used for in CSStransition and i'd expect that if you wanted to incorporate a delay used you the transition-delay property ideally, not a I still think this is valuable feature and my original thought still stands, this could be implemented on top of this library, not integrated into it, using the currently available API. So someone could use the existing pieces here to build a StaggeredTransitionGroup |
I've been working on a set of wrappers and |
Addresses #73 for adding Staggered / Sequenced transition support.
The approach here is to allow a new
staggerTime
property on theTransitionGroup
component.This
staggerTime
is used to apply an inline style object containing atransition-delay
CSS property to each React Child passed down to theTransitionGroup
, which is calculated with the following formula.Storybook Demo:
I may adjust this PR to support passing down a staggerTime to a Transition child as well, there are some other things that could potentially be added.
There are probably some things I am missing context on, feedback whenever anyone gets the chance would be much appreciated.
cc/ @jquense