-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Request: mode for useTransition to wait for old values to leave before it inserts new values #583
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
Comments
have you tried trail? trail: 100,
order: ['leave', 'enter', 'update], please let me know how it's going ... |
@chuckdries Did you found a solution? I have the same problem when umounting/fade left and mounting/fade in components, right now they overlap because the new one doesn't wait until the previous one fades out to fade in. |
I don't think there's a solution for this yet. 😢 If anyone wants to get a PoC going, please build on top of #808 instead of |
I used your workaround ( It's a shame that this workaround wouldn't work without a My transition values sample in case it helps someone: {
from: { fontSize: 0 },
enter: { fontSize: 100 },
leave: { fontSize: 0 },
trail: ANIMATION_DURATION,
config: { duration: ANIMATION_DURATION },
order: ["leave", "enter", "update"]
} Anyway, thanks. |
Closing in favour of #1064 as that contains a POC |
I'm basically asking for Vue's transition out-in mode, where the leaving state finishes before the entering value exists at all.
Toggle Between Components
Take the following example lifted from the useTransition docs:
when
toggle
flips from false to true, the transitions array looks like this over time:With my hypothetical out-in mode, new values don't enter until old values leave. The transitions array would look like this:
In this example, only one item ever exists in the array at a time, but that's probably not true of all situations where this flag would work
Real life
My use case is a button which displays a call to action, then after clicked it displays a success confirmation. I want the states to fade, but I don't want them to fade over each other, I want the call to action to fade out, then the confirmation to fade in.
Below is a demonstration of the behavior I previously made by applying CSS classes with timeouts:
I ended up emulating this functionality multi stage transitions, but I had to add an unused stage to delay the enter, and interpolate a nonsense variable in that stage because if a stage doesn't need to change anything it ends immediately.
https://codesandbox.io/s/34q346788p?fontsize=14
I'm wondering if there's a better approach with the APIs we have today, but I would still like this hypothetical in-out mode as this behavior is one I frequently want.
Thank you for all of your hard work on this incredible library!
The text was updated successfully, but these errors were encountered: