Skip to content

fix: delay use transition #1791

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

Merged
merged 3 commits into from
Dec 20, 2021
Merged

Conversation

joshuaellis
Copy link
Member

Why

Summary of Issue

delays are attached in the scheduleProps function where we make our paused, resume queues because scheduleProps is called in a raf loop. But the specific call to scheduleProps is from a SpringValue so that classes' _state has the information that we're actually paused and waiting for something (the delay).

However, the Controller's state doesnt have the information that it's springs are paused (this is the problem // bug) so when when we call onResolve in the useTransition hook the Controller is seen as idle, it's then removed and forceUpdate is called thus cleaning out the transitions array removing the item.

This wouldn't happen normally because the state update would cause the springs to begin animating thus the Controller would not be idle.

What

Added the isDelayed prop to SpringValue so that a Controller when checking if it's (the Controller) idle will now check that its springs are not delayed. This therefore does not remove the item and the leave animation phase can run.

Checklist

  • Demo added
  • Ready to be merged

@vercel
Copy link

vercel bot commented Dec 20, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pmndrs/react-spring-io/9Bp1AtVj8s4JcyDNSiMY5bZSsetd
✅ Preview: https://react-spring-io-git-fix-delay-usetransition-pmndrs.vercel.app

@joshuaellis joshuaellis linked an issue Dec 20, 2021 that may be closed by this pull request
@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit a02e083:

Sandbox Source
spring-animating-auto Configuration
spring-card Configuration
spring-cards-stack Configuration
spring-draggable-list Configuration
pmndrs/react-spring Configuration
pmndrs/react-spring Configuration
pmndrs/react-spring Configuration
pmndrs/react-spring Configuration
spring-slide Configuration
spring-tree Configuration
naughty-chatelet-b1o3x Issue #1662

@joshuaellis joshuaellis merged commit b15276c into release/9.4.0 Dec 20, 2021
@joshuaellis joshuaellis deleted the fix/delay-useTransition branch December 20, 2021 15:44
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.

useTransition does not run "leave" transition when delay is set
1 participant