-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Nested transitions causing elements to animate IN when unmounting #128
Comments
@mattgreenfield this doesn't look correct to me, the nested transition has no reason to ever go into leave, because the key is always the same. When the parent transition exits out, it will simply remove the nested transition. Transition tracks addition and removal of its own children, if the transition itself is being removed, it can't animate its children out (react simply calls componentWillUnmount and that's it). You also duplicate keys, after pressing add three times there are 2 elements with the keyname "two". Have you looked into alternatives? For instance, the config prop can be a function that gives you the name of the prop that animates, so you can animate the background slower than the foreground. config={name => {
switch(name) {
case 'opacity': return { tension: 10, friction: 20 }
case 'transition': return { tension: 10, friction: 40 }
}
}} Or perhaps keyframes, like this: https://codesandbox.io/embed/zl35mrkqmm |
Thanks so much for the tips @drcmda - I've ended up with what I needed https://codesandbox.io/s/q33qnoz4ow |
@drcmda In the example above provided by @mattgreenfield , how to make the same transition work if the component is unmounting on close? currently only the opacity and transform change. |
Could you adapt the sandbox with updated dependencies and the props you'd like to animate? |
So I want the modal to be in the DOM only when it's open. In mattgreenfield's the element is always present with opacity:0. I want to animate the same props (need similar animation) but the only change is that I want to mount/unmount the component based on state. Here is the updated sandbox. |
I ended up setting a timeout in my |
@ritz078 for mount/unmount you should use the Transition component, your modal would then enter-in or exit-out and then disappear/unmount |
I'm trying to nest transitions so that the background fades in and the text content slides in.
It works find when a component transitions in but when un-mounting, the first transition (fade) leaves correctly but the second transition (slide) enters again.
I have a sandbox, you can see the text slides up from the bottom again when you remove an item, rather than sliding from the center back down - https://codesandbox.io/s/1z30zm6z8l
You'll note that this demo doesn't support adding more than 2 items are i've hard coded the keys :(
It seems it could be related to this #118 but no amount of moving keys around seems to help me.
Any help would be much appreciated. It may be that this isn't even possible with this library?
Thanks,
The text was updated successfully, but these errors were encountered: