Skip to content

skipAnimation not working as expected with delay prop #1783

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 22, 2021

Conversation

martyan
Copy link
Contributor

@martyan martyan commented Dec 9, 2021

Why

As seen in this doc, skipAnimation prop should: skip animations and jump straight to the 'to' value.
Which is what it does. But it applies the delay first (when defined ofc).

Test below is based on the one from the linked docs. Only added delay to the animation. I want to test the to value as in the original test.

Globals.assign({ skipAnimation: true })
...
it('sets opacity to 1', () => {
  const { container } = render(<DelayedThing delay={2000} />)
  expect(container).toHaveStyle({ opacity: 1 })
});

Test fails because the delay is applied.

If I expect skipAnimation to finish all animations immediately, I would also expect delay not being applied.

Related discussion & repro code:
#1779

More docs:
https://aleclarson.github.io/react-spring/v9/#The-skipAnimation-global

What

Added skipAnimation check to scheduleProps.

@vercel
Copy link

vercel bot commented Dec 9, 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/33kjD7NJNW4GUZ8nMX4gr1qY6u9G
✅ Preview: https://react-spring-io-git-fork-martyan-fix-skip-animati-cc20d3-pmndrs.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 9, 2021

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 e16462e:

Sandbox Source
spring-card Configuration
spring-goo-blobs Configuration
pmndrs/react-spring Configuration
spring-slide Configuration
spring-draggable-list Configuration
spring-cards-stack Configuration
spring-viewpager Configuration
spring-simple-transition Configuration
spring-image-fade Configuration
spring-list-reordering Configuration
spring-masonry Configuration
spring-animating-auto Configuration
spring-multistage-transition Configuration
spring-chain Configuration
spring-svg-filter Configuration
spring-css-keyframes Configuration
spring-tree Configuration
spring-notification-hub Configuration
initial-rocket Configuration
spring-notification-hub Configuration
spring-notification-hub Configuration

@martyan martyan changed the title fix: do not delay start if Globals.skipAnimation is set G.skipAnimation not working as expected with delay prop Dec 9, 2021
@martyan martyan changed the title G.skipAnimation not working as expected with delay prop skipAnimation not working as expected with delay prop Dec 9, 2021
@joshuaellis
Copy link
Member

Test below is based on the one from the linked docs. Only added delay to the animation. I want to test the to value as in the original test.

Sorry, is this a test that already exists or one you made that thus failed because of the bug? If latter, it would be great to include this text so we're more confident in the future!

@martyan
Copy link
Contributor Author

martyan commented Dec 22, 2021

Here is CSB with both tests.

The first one is example from react-spring docs.
The other one tests the same thing (opacity should be 1) but with delay. The test should pass as the skipAnimation is set. But it fails due to the delay being applied and thus opacity is still 0.

@joshuaellis
Copy link
Member

Sorry, I more meant about including a test or two in our suite, which I have now done.

@martyan
Copy link
Contributor Author

martyan commented Dec 22, 2021

Awesome, thank you! 🔥

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.

2 participants