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
fix: Make decay easing respect the config.precision
prop
#1897
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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 3de005d:
|
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.
Not sure how I missed this so sorry for the late reply, but this is a great catch thank you! I have one small request though, see comment!
config.precision
propconfig.precision
prop
Why
The current behavior for a decay animation is to finish when the difference between the current spring value and the value during the previous frame is less than the arbitrary value of
0.1
. In most cases this is alright, but if the scale of the animation is significantly small, then we start to notice some weird behavior, where the animation seems to stop prematurely. Here's an example codesandbox where you can simulate different scales: https://codesandbox.io/s/react-spring-decay-scale-j5kfqm?file=/src/App.jsOne situation where this is particularly apparent is when using react-spring in combination with react-three-fiber, and animating in world space. Demo here: https://codesandbox.io/s/r3f-inertia-camera-qqhvxk?file=/src/InertiaCamera.js
What
This PR replaces that arbitrary
1.0
value with the same precision value being used for spring easing.I've moved the precision calculation to a slightly higher scope, so that it can be shared between both spring and decay easing.
Checklist