Skip to content

Commit

Permalink
Fixed callback doesn't run when animating to the same value (software…
Browse files Browse the repository at this point in the history
…-mansion#2211)

Currently, when the user wants to animate property to the same value as property has, animation doesn't run and so the animation callback. It might be not intuitive so I changed it, and now callback runs even if the new value is the same as the old one.
  • Loading branch information
jmysliv authored Jul 23, 2021
1 parent 2e8923e commit 4da7fd7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/reanimated2/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ function workletValueSetter(value) {
// this happens when the animation's target value(stored in animation.current until animation.onStart is called) is set to the same value as a current one(this._value)
// built in animations that are not higher order(withTiming, withSpring) hold target value in .current
if (this._value === animation.current && !animation.isHigherOrder) {
animation.callback && animation.callback(true);
return;
}
// animated set
Expand Down
4 changes: 1 addition & 3 deletions src/reanimated2/layoutReanimation/AnimatedRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ runOnUI(() => {
if (finished) {
_stopObservingProgress(tag, finished);
}
if (style.callback) {
style.callback(finished);
}
style.callback && style.callback(finished);
};
configs[tag].sv.value = animation;
_startObservingProgress(tag, sv);
Expand Down

0 comments on commit 4da7fd7

Please sign in to comment.