react-native-reanimated 3.13.0-rc.2 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +8 -2
  2. package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +3 -1
  3. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +58 -33
  4. package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h +19 -9
  5. package/Common/cpp/LayoutAnimations/LayoutAnimationsUtils.cpp +11 -7
  6. package/Common/cpp/LayoutAnimations/LayoutAnimationsUtils.h +14 -6
  7. package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +1 -1
  8. package/Common/cpp/NativeModules/NativeReanimatedModule.h +1 -1
  9. package/Common/cpp/ReanimatedRuntime/WorkletRuntime.cpp +1 -1
  10. package/Common/cpp/ReanimatedRuntime/WorkletRuntime.h +1 -1
  11. package/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp +6 -6
  12. package/Common/cpp/SharedItems/Shareables.cpp +25 -8
  13. package/Common/cpp/SharedItems/Shareables.h +12 -7
  14. package/android/CMakeLists.txt +1 -1
  15. package/android/src/main/cpp/LayoutAnimations.cpp +14 -0
  16. package/android/src/main/cpp/LayoutAnimations.h +5 -0
  17. package/android/src/main/cpp/NativeProxy.cpp +10 -0
  18. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +10 -2
  19. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +2 -0
  20. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +2 -0
  21. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +10 -0
  22. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ScreensHelper.java +83 -0
  23. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +130 -31
  24. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +36 -0
  25. package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/TabNavigatorObserver.java +128 -0
  26. package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +8 -0
  27. package/android/src/reactNativeVersionPatch/RuntimeExecutor/73/com/swmansion/reanimated/NativeProxy.java +6 -0
  28. package/android/src/reactNativeVersionPatch/RuntimeExecutor/latest/com/swmansion/reanimated/NativeProxy.java +6 -0
  29. package/apple/LayoutReanimation/REAAnimationsManager.h +2 -0
  30. package/apple/LayoutReanimation/REAAnimationsManager.m +5 -0
  31. package/apple/LayoutReanimation/REAScreensHelper.h +6 -0
  32. package/apple/LayoutReanimation/REAScreensHelper.m +92 -4
  33. package/apple/LayoutReanimation/REASharedTransitionManager.h +1 -0
  34. package/apple/LayoutReanimation/REASharedTransitionManager.m +254 -55
  35. package/apple/native/NativeProxy.mm +12 -0
  36. package/lib/module/Colors.js +5 -2
  37. package/lib/module/Colors.js.map +1 -1
  38. package/lib/module/UpdateProps.js +8 -8
  39. package/lib/module/UpdateProps.js.map +1 -1
  40. package/lib/module/ViewDescriptorsSet.js +0 -27
  41. package/lib/module/ViewDescriptorsSet.js.map +1 -1
  42. package/lib/module/createAnimatedComponent/InlinePropManager.js +1 -7
  43. package/lib/module/createAnimatedComponent/InlinePropManager.js.map +1 -1
  44. package/lib/module/createAnimatedComponent/PropsFilter.js +1 -6
  45. package/lib/module/createAnimatedComponent/PropsFilter.js.map +1 -1
  46. package/lib/module/createAnimatedComponent/commonTypes.js.map +1 -1
  47. package/lib/module/createAnimatedComponent/createAnimatedComponent.js +1 -5
  48. package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
  49. package/lib/module/hook/commonTypes.js.map +1 -1
  50. package/lib/module/hook/useAnimatedStyle.js +12 -15
  51. package/lib/module/hook/useAnimatedStyle.js.map +1 -1
  52. package/lib/module/hook/useFrameCallback.js +2 -2
  53. package/lib/module/hook/useFrameCallback.js.map +1 -1
  54. package/lib/module/hook/useWorkletCallback.js +1 -1
  55. package/lib/module/hook/useWorkletCallback.js.map +1 -1
  56. package/lib/module/js-reanimated/index.js +3 -28
  57. package/lib/module/js-reanimated/index.js.map +1 -1
  58. package/lib/module/js-reanimated/webUtils.js +9 -0
  59. package/lib/module/js-reanimated/webUtils.js.map +1 -0
  60. package/lib/module/js-reanimated/webUtils.web.js +25 -0
  61. package/lib/module/js-reanimated/webUtils.web.js.map +1 -0
  62. package/lib/module/layoutReanimation/defaultTransitions/CurvedTransition.js +1 -0
  63. package/lib/module/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
  64. package/lib/module/layoutReanimation/defaultTransitions/EntryExitTransition.js +1 -0
  65. package/lib/module/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
  66. package/lib/module/layoutReanimation/defaultTransitions/FadingTransition.js +11 -10
  67. package/lib/module/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
  68. package/lib/module/layoutReanimation/defaultTransitions/JumpingTransition.js +1 -0
  69. package/lib/module/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
  70. package/lib/module/layoutReanimation/defaultTransitions/LinearTransition.js +1 -0
  71. package/lib/module/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
  72. package/lib/module/layoutReanimation/defaultTransitions/SequencedTransition.js +1 -0
  73. package/lib/module/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
  74. package/lib/module/layoutReanimation/web/Easing.web.js +14 -0
  75. package/lib/module/layoutReanimation/web/Easing.web.js.map +1 -0
  76. package/lib/module/layoutReanimation/web/animationParser.js +16 -1
  77. package/lib/module/layoutReanimation/web/animationParser.js.map +1 -1
  78. package/lib/module/layoutReanimation/web/animationsManager.js +25 -8
  79. package/lib/module/layoutReanimation/web/animationsManager.js.map +1 -1
  80. package/lib/module/layoutReanimation/web/componentStyle.js +12 -16
  81. package/lib/module/layoutReanimation/web/componentStyle.js.map +1 -1
  82. package/lib/module/layoutReanimation/web/componentUtils.js +53 -18
  83. package/lib/module/layoutReanimation/web/componentUtils.js.map +1 -1
  84. package/lib/module/layoutReanimation/web/config.js +1 -12
  85. package/lib/module/layoutReanimation/web/config.js.map +1 -1
  86. package/lib/module/layoutReanimation/web/createAnimation.js +21 -2
  87. package/lib/module/layoutReanimation/web/createAnimation.js.map +1 -1
  88. package/lib/module/layoutReanimation/web/domUtils.js +6 -5
  89. package/lib/module/layoutReanimation/web/domUtils.js.map +1 -1
  90. package/lib/module/layoutReanimation/web/transition/Jumping.web.js +43 -0
  91. package/lib/module/layoutReanimation/web/transition/Jumping.web.js.map +1 -0
  92. package/lib/module/platform-specific/RNRenderer.web.js +1 -1
  93. package/lib/module/platform-specific/RNRenderer.web.js.map +1 -1
  94. package/lib/module/platform-specific/jsVersion.js +1 -1
  95. package/lib/module/platform-specific/jsVersion.js.map +1 -1
  96. package/lib/module/platformFunctions/setNativeProps.web.js +1 -3
  97. package/lib/module/platformFunctions/setNativeProps.web.js.map +1 -1
  98. package/lib/typescript/UpdateProps.d.ts +2 -3
  99. package/lib/typescript/ViewDescriptorsSet.d.ts +0 -9
  100. package/lib/typescript/createAnimatedComponent/commonTypes.d.ts +1 -2
  101. package/lib/typescript/hook/commonTypes.d.ts +3 -6
  102. package/lib/typescript/hook/useWorkletCallback.d.ts +1 -1
  103. package/lib/typescript/js-reanimated/index.d.ts +2 -4
  104. package/lib/typescript/js-reanimated/webUtils.d.ts +3 -0
  105. package/lib/typescript/js-reanimated/webUtils.web.d.ts +3 -0
  106. package/lib/typescript/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +1 -0
  107. package/lib/typescript/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +1 -0
  108. package/lib/typescript/layoutReanimation/defaultTransitions/FadingTransition.d.ts +1 -0
  109. package/lib/typescript/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +1 -0
  110. package/lib/typescript/layoutReanimation/defaultTransitions/LinearTransition.d.ts +1 -0
  111. package/lib/typescript/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +1 -0
  112. package/lib/typescript/layoutReanimation/web/Easing.web.d.ts +10 -0
  113. package/lib/typescript/layoutReanimation/web/animationParser.d.ts +1 -2
  114. package/lib/typescript/layoutReanimation/web/componentStyle.d.ts +1 -1
  115. package/lib/typescript/layoutReanimation/web/componentUtils.d.ts +4 -3
  116. package/lib/typescript/layoutReanimation/web/config.d.ts +5 -12
  117. package/lib/typescript/layoutReanimation/web/createAnimation.d.ts +2 -0
  118. package/lib/typescript/layoutReanimation/web/domUtils.d.ts +1 -1
  119. package/lib/typescript/layoutReanimation/web/transition/Jumping.web.d.ts +29 -0
  120. package/lib/typescript/platform-specific/jsVersion.d.ts +1 -1
  121. package/package.json +4 -3
  122. package/src/Colors.ts +5 -2
  123. package/src/UpdateProps.ts +8 -11
  124. package/src/ViewDescriptorsSet.ts +0 -42
  125. package/src/createAnimatedComponent/InlinePropManager.ts +2 -8
  126. package/src/createAnimatedComponent/PropsFilter.tsx +0 -4
  127. package/src/createAnimatedComponent/commonTypes.ts +1 -2
  128. package/src/createAnimatedComponent/createAnimatedComponent.tsx +1 -5
  129. package/src/hook/commonTypes.ts +3 -6
  130. package/src/hook/useAnimatedStyle.ts +9 -26
  131. package/src/hook/useFrameCallback.ts +2 -2
  132. package/src/hook/useWorkletCallback.ts +1 -1
  133. package/src/js-reanimated/index.ts +11 -37
  134. package/src/js-reanimated/webUtils.ts +8 -0
  135. package/src/js-reanimated/webUtils.web.ts +27 -0
  136. package/src/layoutReanimation/defaultTransitions/CurvedTransition.ts +2 -0
  137. package/src/layoutReanimation/defaultTransitions/EntryExitTransition.ts +2 -0
  138. package/src/layoutReanimation/defaultTransitions/FadingTransition.ts +12 -10
  139. package/src/layoutReanimation/defaultTransitions/JumpingTransition.ts +2 -0
  140. package/src/layoutReanimation/defaultTransitions/LinearTransition.ts +2 -0
  141. package/src/layoutReanimation/defaultTransitions/SequencedTransition.ts +2 -0
  142. package/src/layoutReanimation/web/Easing.web.ts +15 -0
  143. package/src/layoutReanimation/web/animationParser.ts +30 -2
  144. package/src/layoutReanimation/web/animationsManager.ts +45 -12
  145. package/src/layoutReanimation/web/componentStyle.ts +13 -16
  146. package/src/layoutReanimation/web/componentUtils.ts +68 -25
  147. package/src/layoutReanimation/web/config.ts +5 -14
  148. package/src/layoutReanimation/web/createAnimation.ts +38 -4
  149. package/src/layoutReanimation/web/domUtils.ts +15 -5
  150. package/src/layoutReanimation/web/transition/Jumping.web.ts +44 -0
  151. package/src/platform-specific/RNRenderer.web.ts +1 -1
  152. package/src/platform-specific/jsVersion.ts +1 -1
  153. package/src/platformFunctions/setNativeProps.web.ts +1 -1
@@ -1,15 +1,7 @@
1
1
  'use strict';
2
- import { useRef } from 'react';
3
2
  import { makeMutable } from './core';
4
3
  import type { SharedValue } from './commonTypes';
5
4
  import type { Descriptor } from './hook/commonTypes';
6
- import { shouldBeUseWeb } from './PlatformChecker';
7
-
8
- export interface ViewRefSet<T> {
9
- items: Set<T>;
10
- add: (item: T) => void;
11
- remove: (item: T) => void;
12
- }
13
5
 
14
6
  export interface ViewDescriptorsSet {
15
7
  shareableViewDescriptors: SharedValue<Descriptor[]>;
@@ -51,37 +43,3 @@ export function makeViewDescriptorsSet(): ViewDescriptorsSet {
51
43
  };
52
44
  return data;
53
45
  }
54
-
55
- const SHOULD_BE_USE_WEB = shouldBeUseWeb();
56
-
57
- export const useViewRefSet = SHOULD_BE_USE_WEB
58
- ? useViewRefSetJS
59
- : useViewRefSetNative;
60
-
61
- function useViewRefSetNative() {
62
- // Stub native implementation.
63
- return undefined;
64
- }
65
-
66
- function useViewRefSetJS<T>(): ViewRefSet<T> {
67
- const ref = useRef<ViewRefSet<T> | null>(null);
68
- if (ref.current === null) {
69
- const data: ViewRefSet<T> = {
70
- items: new Set(),
71
-
72
- add: (item: T) => {
73
- if (data.items.has(item)) {
74
- return;
75
- }
76
- data.items.add(item);
77
- },
78
-
79
- remove: (item: T) => {
80
- data.items.delete(item);
81
- },
82
- };
83
- ref.current = data;
84
- }
85
-
86
- return ref.current;
87
- }
@@ -8,14 +8,11 @@ import type {
8
8
  } from './commonTypes';
9
9
  import { flattenArray } from './utils';
10
10
  import { makeViewDescriptorsSet } from '../ViewDescriptorsSet';
11
- import type { ViewDescriptorsSet, ViewRefSet } from '../ViewDescriptorsSet';
11
+ import type { ViewDescriptorsSet } from '../ViewDescriptorsSet';
12
12
  import { adaptViewConfig } from '../ConfigHelper';
13
13
  import updateProps from '../UpdateProps';
14
14
  import { stopMapper, startMapper } from '../mappers';
15
15
  import { isSharedValue } from '../isSharedValue';
16
- import { shouldBeUseWeb } from '../PlatformChecker';
17
-
18
- const SHOULD_BE_USE_WEB = shouldBeUseWeb();
19
16
 
20
17
  function isInlineStyleTransform(transform: unknown): boolean {
21
18
  if (!Array.isArray(transform)) {
@@ -160,13 +157,10 @@ export class InlinePropManager implements IInlinePropManager {
160
157
  const shareableViewDescriptors =
161
158
  this._inlinePropsViewDescriptors.shareableViewDescriptors;
162
159
 
163
- const maybeViewRef = SHOULD_BE_USE_WEB
164
- ? ({ items: new Set([animatedComponent]) } as ViewRefSet<unknown>) // see makeViewsRefSet
165
- : undefined;
166
160
  const updaterFunction = () => {
167
161
  'worklet';
168
162
  const update = getInlinePropsUpdate(newInlineProps);
169
- updateProps(shareableViewDescriptors, update, maybeViewRef);
163
+ updateProps(shareableViewDescriptors, update);
170
164
  };
171
165
  this._inlineProps = newInlineProps;
172
166
  if (this._inlinePropsMapperId) {
@@ -47,8 +47,6 @@ export class PropsFilter implements IPropsFilter {
47
47
  const processedStyle: StyleProps = styles.map((style) => {
48
48
  if (style && style.viewDescriptors) {
49
49
  // this is how we recognize styles returned by useAnimatedStyle
50
- // TODO - refactor, since `viewsRef` is only present on Web
51
- style.viewsRef?.add(component);
52
50
  if (this._requiresNewInitials) {
53
51
  this._initialStyle = {
54
52
  ...style.initial.value,
@@ -72,8 +70,6 @@ export class PropsFilter implements IPropsFilter {
72
70
  Object.keys(animatedProp.initial.value).forEach((initialValueKey) => {
73
71
  props[initialValueKey] =
74
72
  animatedProp.initial?.value[initialValueKey];
75
- // TODO - refacotr, since `viewsRef` is only present on Web
76
- animatedProp.viewsRef?.add(component);
77
73
  });
78
74
  }
79
75
  } else if (
@@ -6,7 +6,7 @@ import type {
6
6
  StyleProps,
7
7
  } from '../commonTypes';
8
8
  import type { ViewConfig } from '../ConfigHelper';
9
- import type { ViewDescriptorsSet, ViewRefSet } from '../ViewDescriptorsSet';
9
+ import type { ViewDescriptorsSet } from '../ViewDescriptorsSet';
10
10
  import type {
11
11
  BaseAnimationBuilder,
12
12
  EntryExitAnimationFunction,
@@ -17,7 +17,6 @@ import type { SkipEnteringContext } from '../component/LayoutAnimationConfig';
17
17
 
18
18
  export interface AnimatedProps extends Record<string, unknown> {
19
19
  viewDescriptors?: ViewDescriptorsSet;
20
- viewsRef?: ViewRefSet<unknown>;
21
20
  initial?: SharedValue<StyleProps>;
22
21
  }
23
22
 
@@ -239,11 +239,7 @@ export function createAnimatedComponent(
239
239
  }
240
240
 
241
241
  _detachStyles() {
242
- if (IS_WEB && this._styles !== null) {
243
- for (const style of this._styles) {
244
- style.viewsRef.remove(this);
245
- }
246
- } else if (this._componentViewTag !== -1 && this._styles !== null) {
242
+ if (this._componentViewTag !== -1 && this._styles !== null) {
247
243
  for (const style of this._styles) {
248
244
  style.viewDescriptors.remove(this._componentViewTag);
249
245
  }
@@ -13,13 +13,14 @@ import type {
13
13
  ViewStyle,
14
14
  NativeScrollEvent,
15
15
  } from 'react-native';
16
- import type { ViewDescriptorsSet, ViewRefSet } from '../ViewDescriptorsSet';
16
+ import type { ViewDescriptorsSet } from '../ViewDescriptorsSet';
17
17
  import type { AnimatedStyle } from '../helperTypes';
18
+ import type { ReanimatedHTMLElement } from '../js-reanimated';
18
19
 
19
20
  export type DependencyList = Array<unknown> | undefined;
20
21
 
21
22
  export interface Descriptor {
22
- tag: number;
23
+ tag: number | ReanimatedHTMLElement;
23
24
  name: string;
24
25
  shadowNodeWrapper: ShadowNodeWrapper;
25
26
  }
@@ -96,10 +97,6 @@ export interface AnimatedStyleHandle<
96
97
  value: AnimatedStyle<Style>;
97
98
  updater: () => AnimatedStyle<Style>;
98
99
  };
99
- /**
100
- * @remarks `viewsRef` is only defined in Web implementation.
101
- */
102
- viewsRef: ViewRefSet<unknown> | undefined;
103
100
  }
104
101
 
105
102
  export interface JestAnimatedStyleHandle<
@@ -19,8 +19,8 @@ import type {
19
19
  Descriptor,
20
20
  JestAnimatedStyleHandle,
21
21
  } from './commonTypes';
22
- import type { ViewDescriptorsSet, ViewRefSet } from '../ViewDescriptorsSet';
23
- import { makeViewDescriptorsSet, useViewRefSet } from '../ViewDescriptorsSet';
22
+ import type { ViewDescriptorsSet } from '../ViewDescriptorsSet';
23
+ import { makeViewDescriptorsSet } from '../ViewDescriptorsSet';
24
24
  import { isJest, shouldBeUseWeb } from '../PlatformChecker';
25
25
  import type {
26
26
  AnimationObject,
@@ -178,7 +178,6 @@ function styleUpdater(
178
178
  viewDescriptors: SharedValue<Descriptor[]>,
179
179
  updater: WorkletFunction<[], AnimatedStyle<any>> | (() => AnimatedStyle<any>),
180
180
  state: AnimatedState,
181
- maybeViewRef: ViewRefSet<any> | undefined,
182
181
  animationsActive: SharedValue<boolean>,
183
182
  isAnimatedProps = false
184
183
  ): void {
@@ -234,7 +233,7 @@ function styleUpdater(
234
233
  }
235
234
 
236
235
  if (updates) {
237
- updateProps(viewDescriptors, updates, maybeViewRef);
236
+ updateProps(viewDescriptors, updates);
238
237
  }
239
238
 
240
239
  if (!allFinished) {
@@ -252,14 +251,14 @@ function styleUpdater(
252
251
  }
253
252
 
254
253
  if (hasNonAnimatedValues) {
255
- updateProps(viewDescriptors, nonAnimatedNewValues, maybeViewRef);
254
+ updateProps(viewDescriptors, nonAnimatedNewValues);
256
255
  }
257
256
  } else {
258
257
  state.isAnimationCancelled = true;
259
258
  state.animations = [];
260
259
 
261
260
  if (!shallowEqual(oldValues, newValues)) {
262
- updateProps(viewDescriptors, newValues, maybeViewRef, isAnimatedProps);
261
+ updateProps(viewDescriptors, newValues, isAnimatedProps);
263
262
  }
264
263
  }
265
264
  state.last = newValues;
@@ -269,7 +268,6 @@ function jestStyleUpdater(
269
268
  viewDescriptors: SharedValue<Descriptor[]>,
270
269
  updater: WorkletFunction<[], AnimatedStyle<any>> | (() => AnimatedStyle<any>),
271
270
  state: AnimatedState,
272
- maybeViewRef: ViewRefSet<any> | undefined,
273
271
  animationsActive: SharedValue<boolean>,
274
272
  animatedStyle: MutableRefObject<AnimatedStyle<any>>,
275
273
  adapters: AnimatedPropsAdapterFunction[]
@@ -326,13 +324,7 @@ function jestStyleUpdater(
326
324
  });
327
325
 
328
326
  if (Object.keys(updates).length) {
329
- updatePropsJestWrapper(
330
- viewDescriptors,
331
- updates,
332
- maybeViewRef,
333
- animatedStyle,
334
- adapters
335
- );
327
+ updatePropsJestWrapper(viewDescriptors, updates, animatedStyle, adapters);
336
328
  }
337
329
 
338
330
  if (!allFinished) {
@@ -358,13 +350,7 @@ function jestStyleUpdater(
358
350
  state.last = newValues;
359
351
 
360
352
  if (!shallowEqual(oldValues, newValues)) {
361
- updatePropsJestWrapper(
362
- viewDescriptors,
363
- newValues,
364
- maybeViewRef,
365
- animatedStyle,
366
- adapters
367
- );
353
+ updatePropsJestWrapper(viewDescriptors, newValues, animatedStyle, adapters);
368
354
  }
369
355
  }
370
356
 
@@ -423,7 +409,6 @@ export function useAnimatedStyle<Style extends DefaultStyle>(
423
409
  adapters?: AnimatedPropsAdapterWorklet | AnimatedPropsAdapterWorklet[] | null,
424
410
  isAnimatedProps = false
425
411
  ): AnimatedStyleHandle<Style> | JestAnimatedStyleHandle<Style> {
426
- const viewsRef: ViewRefSet<unknown> | undefined = useViewRefSet();
427
412
  const animatedUpdaterData = useRef<AnimatedUpdaterData>();
428
413
  let inputs = Object.values(updater.__closure ?? {});
429
414
  if (SHOULD_BE_USE_WEB) {
@@ -506,7 +491,6 @@ For more, see the docs: \`https://docs.swmansion.com/react-native-reanimated/doc
506
491
  shareableViewDescriptors,
507
492
  updater,
508
493
  remoteState,
509
- viewsRef,
510
494
  areAnimationsActive,
511
495
  jestAnimatedStyle,
512
496
  adaptersArray
@@ -519,7 +503,6 @@ For more, see the docs: \`https://docs.swmansion.com/react-native-reanimated/doc
519
503
  shareableViewDescriptors,
520
504
  updaterFn,
521
505
  remoteState,
522
- viewsRef,
523
506
  areAnimationsActive,
524
507
  isAnimatedProps
525
508
  );
@@ -547,8 +530,8 @@ For more, see the docs: \`https://docs.swmansion.com/react-native-reanimated/doc
547
530
 
548
531
  if (!animatedStyleHandle.current) {
549
532
  animatedStyleHandle.current = isJest()
550
- ? { viewDescriptors, initial, viewsRef, jestAnimatedStyle }
551
- : { initial, viewsRef, viewDescriptors };
533
+ ? { viewDescriptors, initial, jestAnimatedStyle }
534
+ : { viewDescriptors, initial };
552
535
  }
553
536
 
554
537
  return animatedStyleHandle.current;
@@ -43,11 +43,11 @@ export function useFrameCallback(
43
43
  useEffect(() => {
44
44
  ref.current.callbackId =
45
45
  frameCallbackRegistry.registerFrameCallback(callback);
46
+ const memoizedId = ref.current.callbackId;
46
47
  ref.current.setActive(ref.current.isActive);
47
48
 
48
49
  return () => {
49
- frameCallbackRegistry.unregisterFrameCallback(ref.current.callbackId);
50
- ref.current.callbackId = -1;
50
+ frameCallbackRegistry.unregisterFrameCallback(memoizedId);
51
51
  };
52
52
  }, [callback, autostart]);
53
53
 
@@ -3,7 +3,7 @@ import { useCallback } from 'react';
3
3
  import type { DependencyList } from './commonTypes';
4
4
 
5
5
  /**
6
- * @deprecated don't use
6
+ * @deprecated use React.useCallback instead
7
7
  */
8
8
  export function useWorkletCallback<Args extends unknown[], ReturnValue>(
9
9
  worklet: (...args: Args) => ReturnValue,
@@ -2,37 +2,13 @@
2
2
  import JSReanimated from './JSReanimated';
3
3
  import type { StyleProps } from '../commonTypes';
4
4
  import type { AnimatedStyle } from '../helperTypes';
5
- import { isWeb } from '../PlatformChecker';
5
+ import {
6
+ createReactDOMStyle,
7
+ createTransformValue,
8
+ createTextShadowValue,
9
+ } from './webUtils';
6
10
  import { PropsAllowlists } from '../propsAllowlists';
7
11
 
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- let createReactDOMStyle: (style: any) => any;
10
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
- let createTransformValue: (transform: any) => any;
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- let createTextShadowValue: (style: any) => void | string;
14
-
15
- if (isWeb()) {
16
- try {
17
- createReactDOMStyle =
18
- // eslint-disable-next-line @typescript-eslint/no-var-requires
19
- require('react-native-web/dist/exports/StyleSheet/compiler/createReactDOMStyle').default;
20
- } catch (e) {}
21
-
22
- try {
23
- // React Native Web 0.19+
24
- createTransformValue =
25
- // eslint-disable-next-line @typescript-eslint/no-var-requires
26
- require('react-native-web/dist/exports/StyleSheet/preprocess').createTransformValue;
27
- } catch (e) {}
28
-
29
- try {
30
- createTextShadowValue =
31
- // eslint-disable-next-line @typescript-eslint/no-var-requires
32
- require('react-native-web/dist/exports/StyleSheet/preprocess').createTextShadowValue;
33
- } catch (e) {}
34
- }
35
-
36
12
  const reanimatedJS = new JSReanimated();
37
13
 
38
14
  global._makeShareableClone = () => {
@@ -77,17 +53,15 @@ export interface ReanimatedHTMLElement extends HTMLElement {
77
53
  export const _updatePropsJS = (
78
54
  // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
79
55
  updates: StyleProps | AnimatedStyle<any>,
80
- viewRef: {
81
- _component?: (JSReanimatedComponent | ReanimatedHTMLElement) & {
82
- getAnimatableRef?: () => JSReanimatedComponent | ReanimatedHTMLElement;
83
- };
56
+ viewRef: (JSReanimatedComponent | ReanimatedHTMLElement) & {
57
+ getAnimatableRef?: () => JSReanimatedComponent | ReanimatedHTMLElement;
84
58
  },
85
59
  isAnimatedProps?: boolean
86
60
  ): void => {
87
- if (viewRef._component) {
88
- const component = viewRef._component.getAnimatableRef
89
- ? viewRef._component.getAnimatableRef()
90
- : viewRef._component;
61
+ if (viewRef) {
62
+ const component = viewRef.getAnimatableRef
63
+ ? viewRef.getAnimatableRef()
64
+ : viewRef;
91
65
  const [rawStyles] = Object.keys(updates).reduce(
92
66
  (acc: [StyleProps, AnimatedStyle<any>], key) => {
93
67
  const value = updates[key];
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ export let createReactDOMStyle: (style: any) => any;
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ export let createTransformValue: (transform: any) => any;
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ export let createTextShadowValue: (style: any) => void | string;
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ export let createReactDOMStyle: (style: any) => any;
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ export let createTransformValue: (transform: any) => any;
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ export let createTextShadowValue: (style: any) => void | string;
9
+
10
+ try {
11
+ createReactDOMStyle =
12
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
13
+ require('react-native-web/dist/exports/StyleSheet/compiler/createReactDOMStyle').default;
14
+ } catch (e) {}
15
+
16
+ try {
17
+ // React Native Web 0.19+
18
+ createTransformValue =
19
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
20
+ require('react-native-web/dist/exports/StyleSheet/preprocess').createTransformValue;
21
+ } catch (e) {}
22
+
23
+ try {
24
+ createTextShadowValue =
25
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
26
+ require('react-native-web/dist/exports/StyleSheet/preprocess').createTextShadowValue;
27
+ } catch (e) {}
@@ -20,6 +20,8 @@ export class CurvedTransition
20
20
  extends BaseAnimationBuilder
21
21
  implements ILayoutAnimationBuilder
22
22
  {
23
+ static presetName = 'CurvedTransition';
24
+
23
25
  easingXV: EasingFunction = Easing.in(Easing.ease);
24
26
  easingYV: EasingFunction = Easing.out(Easing.ease);
25
27
  easingWidthV: EasingFunction = Easing.in(Easing.exp);
@@ -15,6 +15,8 @@ export class EntryExitTransition
15
15
  extends BaseAnimationBuilder
16
16
  implements ILayoutAnimationBuilder
17
17
  {
18
+ static presetName = 'EntryExitTransition';
19
+
18
20
  enteringV: BaseAnimationBuilder | typeof BaseAnimationBuilder = FadeIn;
19
21
 
20
22
  exitingV: BaseAnimationBuilder | typeof BaseAnimationBuilder = FadeOut;
@@ -1,5 +1,5 @@
1
1
  'use strict';
2
- import { withSequence, withTiming } from '../../animation';
2
+ import { withDelay, withSequence, withTiming } from '../../animation';
3
3
  import type {
4
4
  ILayoutAnimationBuilder,
5
5
  LayoutAnimationFunction,
@@ -17,6 +17,8 @@ export class FadingTransition
17
17
  extends BaseAnimationBuilder
18
18
  implements ILayoutAnimationBuilder
19
19
  {
20
+ static presetName = 'FadingTransition';
21
+
20
22
  static createInstance<T extends typeof BaseAnimationBuilder>(
21
23
  this: T
22
24
  ): InstanceType<T> {
@@ -27,7 +29,7 @@ export class FadingTransition
27
29
  const delayFunction = this.getDelayFunction();
28
30
  const callback = this.callbackV;
29
31
  const delay = this.getDelay();
30
- const duration = this.durationV ?? 500;
32
+ const duration = (this.durationV ?? 500) / 2;
31
33
 
32
34
  return (values) => {
33
35
  'worklet';
@@ -47,21 +49,21 @@ export class FadingTransition
47
49
  withTiming(1, { duration })
48
50
  )
49
51
  ),
50
- originX: delayFunction(
52
+ originX: withDelay(
51
53
  delay + duration,
52
- withTiming(values.targetOriginX, { duration: 50 })
54
+ withTiming(values.targetOriginX, { duration: 0 })
53
55
  ),
54
- originY: delayFunction(
56
+ originY: withDelay(
55
57
  delay + duration,
56
- withTiming(values.targetOriginY, { duration: 50 })
58
+ withTiming(values.targetOriginY, { duration: 0 })
57
59
  ),
58
- width: delayFunction(
60
+ width: withDelay(
59
61
  delay + duration,
60
- withTiming(values.targetWidth, { duration: 50 })
62
+ withTiming(values.targetWidth, { duration: 0 })
61
63
  ),
62
- height: delayFunction(
64
+ height: withDelay(
63
65
  delay + duration,
64
- withTiming(values.targetHeight, { duration: 50 })
66
+ withTiming(values.targetHeight, { duration: 0 })
65
67
  ),
66
68
  },
67
69
  callback,
@@ -18,6 +18,8 @@ export class JumpingTransition
18
18
  extends BaseAnimationBuilder
19
19
  implements ILayoutAnimationBuilder
20
20
  {
21
+ static presetName = 'JumpingTransition';
22
+
21
23
  static createInstance<T extends typeof BaseAnimationBuilder>(
22
24
  this: T
23
25
  ): InstanceType<T> {
@@ -17,6 +17,8 @@ export class LinearTransition
17
17
  extends ComplexAnimationBuilder
18
18
  implements ILayoutAnimationBuilder
19
19
  {
20
+ static presetName = 'LinearTransition';
21
+
20
22
  static createInstance<T extends typeof BaseAnimationBuilder>(
21
23
  this: T
22
24
  ): InstanceType<T> {
@@ -17,6 +17,8 @@ export class SequencedTransition
17
17
  extends BaseAnimationBuilder
18
18
  implements ILayoutAnimationBuilder
19
19
  {
20
+ static presetName = 'SequencedTransition';
21
+
20
22
  reversed = false;
21
23
 
22
24
  static createInstance<T extends typeof BaseAnimationBuilder>(
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ // Those are the easings that can be implemented using Bezier curves.
4
+ // Others should be done as CSS animations
5
+ export const WebEasings = {
6
+ linear: [0, 0, 1, 1],
7
+ ease: [0.42, 0, 1, 1],
8
+ quad: [0.11, 0, 0.5, 0],
9
+ cubic: [0.32, 0, 0.67, 0],
10
+ sin: [0.12, 0, 0.39, 0],
11
+ circle: [0.55, 0, 1, 0.45],
12
+ exp: [0.7, 0, 0.84, 0],
13
+ };
14
+
15
+ export type WebEasingsNames = keyof typeof WebEasings;
@@ -1,5 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ import { WebEasings } from './Easing.web';
4
+ import type { WebEasingsNames } from './Easing.web';
5
+
3
6
  export interface ReanimatedWebTransformProperties {
4
7
  translateX?: string;
5
8
  translateY?: string;
@@ -14,7 +17,7 @@ export interface ReanimatedWebTransformProperties {
14
17
  skewX?: string;
15
18
  }
16
19
 
17
- interface AnimationStyle {
20
+ export interface AnimationStyle {
18
21
  opacity?: number;
19
22
  transform?: ReanimatedWebTransformProperties[];
20
23
  }
@@ -39,9 +42,34 @@ export function convertAnimationObjectToKeyframes(
39
42
  let keyframe = `@keyframes ${animationObject.name} { `;
40
43
 
41
44
  for (const [timestamp, style] of Object.entries(animationObject.style)) {
42
- keyframe += `${timestamp}% { `;
45
+ const step =
46
+ timestamp === 'from' ? 0 : timestamp === 'to' ? 100 : timestamp;
47
+
48
+ keyframe += `${step}% { `;
43
49
 
44
50
  for (const [property, values] of Object.entries(style)) {
51
+ if (property === 'easing') {
52
+ const easingName = (
53
+ values.name in WebEasings ? values.name : 'linear'
54
+ ) as WebEasingsNames;
55
+
56
+ keyframe += `animation-timing-function: cubic-bezier(${WebEasings[
57
+ easingName
58
+ ].toString()});`;
59
+
60
+ continue;
61
+ }
62
+
63
+ if (property === 'originX') {
64
+ keyframe += `left: ${values}px; `;
65
+ continue;
66
+ }
67
+
68
+ if (property === 'originY') {
69
+ keyframe += `top: ${values}px; `;
70
+ continue;
71
+ }
72
+
45
73
  if (property !== 'transform') {
46
74
  keyframe += `${property}: ${values}; `;
47
75
  continue;