Skip to content

Commit 9114183

Browse files
authored
fix: Animation assignment with compiler-safe API (software-mansion#6715)
## Summary When I added compiler-safe API for shared values, I accidentally forgot that animations exist and that their assignment to shared values has to be handled separately. Fixes - software-mansion#6613 ## Test plan Added relevant runtime test suite and adjusted some others.
1 parent 93f3d84 commit 9114183

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/animation/util.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,9 @@ export function defineAnimation<
528528
if (_WORKLET || SHOULD_BE_USE_WEB) {
529529
return create();
530530
}
531-
// @ts-ignore: eslint-disable-line
531+
create.__isAnimationDefinition = true;
532+
533+
// @ts-expect-error it's fine
532534
return create;
533535
}
534536

src/mutables.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,14 @@ function addCompilerSafeGetAndSet<Value>(mutable: PartialMutable<Value>): void {
5858
},
5959
set: {
6060
value(newValue: Value | ((value: Value) => Value)) {
61-
if (typeof newValue === 'function') {
61+
if (
62+
typeof newValue === 'function' &&
63+
// If we have an animation definition, we don't want to call it here.
64+
!(newValue as Record<string, unknown>).__isAnimationDefinition
65+
) {
6266
mutable.value = (newValue as (value: Value) => Value)(mutable.value);
6367
} else {
64-
mutable.value = newValue;
68+
mutable.value = newValue as Value;
6569
}
6670
},
6771
configurable: false,

0 commit comments

Comments
 (0)