Skip to content

Commit

Permalink
Provide correct types to prevent implicit casting boolean to integer (s…
Browse files Browse the repository at this point in the history
…oftware-mansion#4606)

<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect. -->

## Summary
Just a simple refactor
<!-- Explain the motivation for this PR. Include "Fixes #<number>" if
applicable. -->

## Test plan

<!-- Provide a minimal but complete code snippet that can be used to
test out this change along with instructions how to run it and a
description of the expected behavior. -->

Co-authored-by: Aleksandra Cynk <aleksandracynk@swmansion.com>
  • Loading branch information
Latropos and Aleksandra Cynk authored Jun 22, 2023
1 parent 05b9bb6 commit d1597ff
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/reanimated2/animation/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,9 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
let finished = true;
tab.forEach((i, index) => {
animation[i].current = RGBACurrent[index];
// @ts-ignore: disable-next-line
finished &= animation[i].onFrame(animation[i], timestamp);
const result = animation[i].onFrame(animation[i], timestamp);
// We really need to assign this value to result, instead of passing it directly - otherwise once "finished" is false, onFrame won't be called
finished &&= result;
res.push(animation[i].current);
});

Expand Down Expand Up @@ -216,9 +217,10 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
timestamp: Timestamp
): boolean => {
let finished = true;
(animation.current as Array<number>).forEach((v, i) => {
// @ts-ignore: disable-next-line
finished &= animation[i].onFrame(animation[i], timestamp);
(animation.current as Array<number>).forEach((_, i) => {
const result = animation[i].onFrame(animation[i], timestamp);
// We really need to assign this value to result, instead of passing it directly - otherwise once "finished" is false, onFrame won't be called
finished &&= result;
(animation.current as Array<number>)[i] = animation[i].current;
});

Expand Down Expand Up @@ -256,8 +258,9 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
let finished = true;
const newObject: AnimatableValueObject = {};
for (const key in animation.current as AnimatableValueObject) {
// @ts-ignore: disable-next-line
finished &= animation[key].onFrame(animation[key], timestamp);
const result = animation[key].onFrame(animation[key], timestamp);
// We really need to assign this value to result, instead of passing it directly - otherwise once "finished" is false, onFrame won't be called
finished &&= result;
newObject[key] = animation[key].current;
}
animation.current = newObject;
Expand Down

0 comments on commit d1597ff

Please sign in to comment.