-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 "withDecay clamps position to the wrong boundary" #4591
Conversation
src/reanimated2/animation/decay.ts
Outdated
@@ -38,6 +38,7 @@ export interface InnerDecayAnimation | |||
current: number; | |||
} | |||
|
|||
const EPSILON = 0.01; |
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.
Isn't it too much? What about 1e-3
?
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.
@Latropos I know that you discussed this with Tomek offline, but let's write the conclusion in a comment to keep the informations in one place, please 🙏
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.
Sure! We want to have similar precision for decay and withSpring. Also we have tested, that it works well with const EPSILON = 0.01;
and that we animate static spring for long time if epsilon is smaller.
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.
As we discussed it last time, let's merge it, and add more "real life physic" behaviour in another PR.
Summary
Closes #4508
Bug description
Screen.Recording.2023-06-20.at.11.27.36.mov
Screen.Recording.2023-06-26.at.16.48.00.mov
Description of code change
I've removed a condition updating the derivative only when square is within predefined boundaries - since we want to keep its springified movement even if it is overshooting. Especially that we used to end animation almost immediately after exceeding limits.
Since after this change the
derivative
is always modified we should no longer compare it to zero, but use some epsilon instead.Test plan
I've tested it on this example: https://github.com/MatiPl01/reanimated-issues, linked in the issue.