-
-
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
animation not starting if inital value is set to 0
#6769
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ export function valueSetter<Value>( | |
// built in animations that are not higher order(withTiming, withSpring) hold target value in .current | ||
if ( | ||
mutable._value === animation.current && | ||
!animation.forceRunAnimation && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it seems like this check has a purpose (explained above), does introducing this flag not defeat that purpose? i think this needs to be rethought more holistically with the above comment in mind There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to be clear i'm not a maintainer, just thinking based on the code |
||
!animation.isHigherOrder && | ||
!forceUpdate | ||
) { | ||
|
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.
Instead of adding that artificial prop, we should calculate the finish position like we do for
withTiming
, for example. You can see how it's done here: https://github.com/software-mansion/react-native-reanimated/blob/main/packages/react-native-reanimated/src/animation/timing.ts#L154. This solution should be clearer and simplerThere 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 I can see
timing
doesn't rely on previouscurrent
to calculate recentcurrent
value, as thedecay
does it. Wouldn't settingcurrent
in onStart totoValue
break for example thisdecay
function fragment:Just wondering, because even this fragment can be rewritten to support your idea (so not a problem really)
In conclusion, to fully understand, you want to replace the
current
withtoValue
instead of - in this case -0
, so that it will not go into this conditional?Should I also mark it as a
isHigherOrder
as it will hold its target value in.current
?