react-native-reanimated 3.19.0 → 3.19.2
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.
- package/Common/cpp/reanimated/Fabric/PropsRegistry.cpp +13 -15
- package/Common/cpp/reanimated/Fabric/PropsRegistry.h +8 -6
- package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.cpp +138 -34
- package/Common/cpp/reanimated/LayoutAnimations/LayoutAnimationsProxy.h +32 -3
- package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.cpp +27 -14
- package/Common/cpp/reanimated/NativeModules/ReanimatedModuleProxy.h +3 -0
- package/Common/cpp/reanimated/Tools/PlatformDepMethodsHolder.h +9 -1
- package/android/CMakeLists.txt +10 -3
- package/android/build.gradle +3 -3
- package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +19 -0
- package/android/src/main/cpp/reanimated/android/NativeProxy.cpp +37 -12
- package/android/src/main/cpp/reanimated/android/NativeProxy.h +8 -2
- package/android/src/main/java/com/swmansion/worklets/WorkletsMessageQueueThreadBase.java +1 -2
- package/lib/module/ViewDescriptorsSet.js +5 -1
- package/lib/module/ViewDescriptorsSet.js.map +1 -1
- package/lib/module/animation/util.js +5 -3
- package/lib/module/animation/util.js.map +1 -1
- package/lib/module/component/ReducedMotionConfig.js +1 -1
- package/lib/module/createAnimatedComponent/NativeEventsManager.js +1 -1
- package/lib/module/createAnimatedComponent/NativeEventsManager.js.map +1 -1
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js +28 -11
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
- package/lib/module/layoutReanimation/web/Easing.web.js +14 -0
- package/lib/module/layoutReanimation/web/Easing.web.js.map +1 -1
- package/lib/module/layoutReanimation/web/animationParser.js.map +1 -1
- package/lib/module/layoutReanimation/web/componentUtils.js +52 -14
- package/lib/module/layoutReanimation/web/componentUtils.js.map +1 -1
- package/lib/module/layoutReanimation/web/config.js.map +1 -1
- package/lib/module/layoutReanimation/web/createAnimation.js +12 -0
- package/lib/module/layoutReanimation/web/createAnimation.js.map +1 -1
- package/lib/module/layoutReanimation/web/domUtils.js +1 -1
- package/lib/module/layoutReanimation/web/domUtils.js.map +1 -1
- package/lib/module/layoutReanimation/web/transition/Curved.web.js +1 -0
- package/lib/module/layoutReanimation/web/transition/Curved.web.js.map +1 -1
- package/lib/module/platform-specific/jsVersion.js +1 -1
- package/lib/module/platformFunctions/dispatchCommand.js +10 -0
- package/lib/module/platformFunctions/dispatchCommand.js.map +1 -1
- package/lib/module/platformFunctions/scrollTo.web.js +11 -7
- package/lib/module/platformFunctions/scrollTo.web.js.map +1 -1
- package/lib/module/runtimes.js +1 -1
- package/lib/module/threads.js +5 -5
- package/lib/typescript/ViewDescriptorsSet.d.ts +1 -0
- package/lib/typescript/ViewDescriptorsSet.d.ts.map +1 -1
- package/lib/typescript/animation/util.d.ts.map +1 -1
- package/lib/typescript/component/ReducedMotionConfig.d.ts +1 -1
- package/lib/typescript/createAnimatedComponent/createAnimatedComponent.d.ts.map +1 -1
- package/lib/typescript/helperTypes.d.ts +4 -1
- package/lib/typescript/helperTypes.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/web/Easing.web.d.ts +2 -0
- package/lib/typescript/layoutReanimation/web/Easing.web.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/web/animationParser.d.ts +3 -0
- package/lib/typescript/layoutReanimation/web/animationParser.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/web/componentUtils.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/web/config.d.ts +4 -4
- package/lib/typescript/layoutReanimation/web/config.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/web/createAnimation.d.ts.map +1 -1
- package/lib/typescript/layoutReanimation/web/transition/Curved.web.d.ts.map +1 -1
- package/lib/typescript/platform-specific/jsVersion.d.ts +1 -1
- package/lib/typescript/platformFunctions/scrollTo.web.d.ts.map +1 -1
- package/lib/typescript/runtimes.d.ts +1 -1
- package/lib/typescript/threads.d.ts +5 -5
- package/package.json +1 -1
- package/scripts/reanimated_utils.rb +1 -1
- package/src/ViewDescriptorsSet.ts +9 -0
- package/src/animation/util.ts +6 -4
- package/src/component/ReducedMotionConfig.tsx +1 -1
- package/src/createAnimatedComponent/NativeEventsManager.ts +1 -1
- package/src/createAnimatedComponent/createAnimatedComponent.tsx +35 -24
- package/src/helperTypes.ts +5 -1
- package/src/layoutReanimation/web/Easing.web.ts +32 -0
- package/src/layoutReanimation/web/animationParser.ts +3 -0
- package/src/layoutReanimation/web/componentUtils.ts +69 -16
- package/src/layoutReanimation/web/config.ts +7 -3
- package/src/layoutReanimation/web/createAnimation.ts +15 -0
- package/src/layoutReanimation/web/domUtils.ts +1 -1
- package/src/layoutReanimation/web/transition/Curved.web.ts +1 -0
- package/src/platform-specific/jsVersion.ts +1 -1
- package/src/platformFunctions/dispatchCommand.ts +23 -2
- package/src/platformFunctions/scrollTo.web.ts +9 -3
- package/src/runtimes.ts +1 -1
- package/src/threads.ts +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/layoutReanimation/web/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACX,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/layoutReanimation/web/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAoC1D,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEvE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;AAErE,MAAM,MAAM,mBAAmB,GAAG,MAAM,CACtC,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,EAC3B,cAAc,CACf,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,mBAAmB,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,MAAM,CAAC;IACX,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,UAAU,GAAG,qBAAqB,CAAC;IAC7C,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,aAAa,CAAC,EAAE,UAAU,CAAC;CAC5B;AAED,oBAAY,cAAc;IACxB,MAAM,IAAA;IACN,SAAS,IAAA;IACT,MAAM,IAAA;IACN,OAAO,IAAA;IACP,MAAM,IAAA;IACN,UAAU,IAAA;CACX;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAoBxD,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoBtB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,UAAU,CAAC;AACrD,MAAM,MAAM,sBAAsB,GAAG,MAAM,OAAO,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createAnimation.d.ts","sourceRoot":"","sources":["../../../../src/layoutReanimation/web/createAnimation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAGV,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAkB,cAAc,EAAE,MAAM,UAAU,CAAC;AA0C1D,wBAAgB,6BAA6B,CAC3C,mBAAmB,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"createAnimation.d.ts","sourceRoot":"","sources":["../../../../src/layoutReanimation/web/createAnimation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAGV,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,EAAkB,cAAc,EAAE,MAAM,UAAU,CAAC;AA0C1D,wBAAgB,6BAA6B,CAC3C,mBAAmB,EAAE,mBAAmB,UAoCzC;AAED,wBAAgB,gCAAgC,CAC9C,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,uBAAuB,UA6DvC;AAQD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc;;;EAkE/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Curved.web.d.ts","sourceRoot":"","sources":["../../../../../src/layoutReanimation/web/transition/Curved.web.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"Curved.web.d.ts","sourceRoot":"","sources":["../../../../../src/layoutReanimation/web/transition/Curved.web.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAiGjD,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,qBAAqB,EAC9B,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAC9B,2BAA2B,EAAE,MAAM;;;EAYpC;AAED,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;EAoC/B"}
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* version used to build the native part of the library in runtime. Remember to
|
|
4
4
|
* keep this in sync with the version declared in `package.json`
|
|
5
5
|
*/
|
|
6
|
-
export declare const jsVersion = "3.19.
|
|
6
|
+
export declare const jsVersion = "3.19.2";
|
|
7
7
|
//# sourceMappingURL=jsVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrollTo.web.d.ts","sourceRoot":"","sources":["../../../src/platformFunctions/scrollTo.web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"scrollTo.web.d.ts","sourceRoot":"","sources":["../../../src/platformFunctions/scrollTo.web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGvD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,SAAS,EAC1C,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,EAC3B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,OAAO,QAelB"}
|
|
@@ -13,7 +13,7 @@ export type WorkletRuntime = {
|
|
|
13
13
|
* the same thread immediately after the runtime is created.
|
|
14
14
|
* @returns WorkletRuntime which is a
|
|
15
15
|
* `jsi::HostObject<reanimated::WorkletRuntime>` - {@link WorkletRuntime}
|
|
16
|
-
* @see https://docs.swmansion.com/react-native-reanimated/docs/threading/createWorkletRuntime
|
|
16
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/3.x/threading/createWorkletRuntime
|
|
17
17
|
*/
|
|
18
18
|
export declare function createWorkletRuntime(name: string, initializer?: () => void): WorkletRuntime;
|
|
19
19
|
export declare function runOnRuntime<Args extends unknown[], ReturnValue>(workletRuntime: WorkletRuntime, worklet: (...args: Args) => ReturnValue): WorkletFunction<Args, ReturnValue>;
|
|
@@ -5,7 +5,7 @@ export declare const callMicrotasks: () => void;
|
|
|
5
5
|
* Lets you asynchronously run
|
|
6
6
|
* [workletized](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#to-workletize)
|
|
7
7
|
* functions on the [UI
|
|
8
|
-
* thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI).
|
|
8
|
+
* thread](https://docs.swmansion.com/react-native-reanimated/docs/3.x/threading/runOnUI).
|
|
9
9
|
*
|
|
10
10
|
* This method does not schedule the work immediately but instead waits for
|
|
11
11
|
* other worklets to be scheduled within the same JS loop. It uses
|
|
@@ -13,12 +13,12 @@ export declare const callMicrotasks: () => void;
|
|
|
13
13
|
* within the same frame boundaries on the UI thread.
|
|
14
14
|
*
|
|
15
15
|
* @param fun - A reference to a function you want to execute on the [UI
|
|
16
|
-
* thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI)
|
|
16
|
+
* thread](https://docs.swmansion.com/react-native-reanimated/docs/3.x/threading/runOnUI)
|
|
17
17
|
* from the [JavaScript
|
|
18
|
-
* thread](https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI).
|
|
18
|
+
* thread](https://docs.swmansion.com/react-native-reanimated/docs/3.x/threading/runOnUI).
|
|
19
19
|
* @returns A function that accepts arguments for the function passed as the
|
|
20
20
|
* first argument.
|
|
21
|
-
* @see https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnUI
|
|
21
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/3.x/threading/runOnUI
|
|
22
22
|
*/
|
|
23
23
|
export declare function runOnUI<Args extends unknown[], ReturnValue>(worklet: (...args: Args) => ReturnValue): (...args: Args) => void;
|
|
24
24
|
export declare function executeOnUIRuntimeSync<Args extends unknown[], ReturnValue>(worklet: (...args: Args) => ReturnValue): (...args: Args) => ReturnValue;
|
|
@@ -42,7 +42,7 @@ type RemoteFunction<Args extends unknown[], ReturnValue> = ReleaseRemoteFunction
|
|
|
42
42
|
* thread from the UI thread.
|
|
43
43
|
* @returns A function that accepts arguments for the function passed as the
|
|
44
44
|
* first argument.
|
|
45
|
-
* @see https://docs.swmansion.com/react-native-reanimated/docs/threading/runOnJS
|
|
45
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/3.x/threading/runOnJS
|
|
46
46
|
*/
|
|
47
47
|
export declare function runOnJS<Args extends unknown[], ReturnValue>(fun: ((...args: Args) => ReturnValue) | RemoteFunction<Args, ReturnValue> | WorkletFunction<Args, ReturnValue>): (...args: Args) => void;
|
|
48
48
|
export {};
|
package/package.json
CHANGED
|
@@ -53,7 +53,7 @@ end
|
|
|
53
53
|
|
|
54
54
|
def assert_minimal_react_native_version(config)
|
|
55
55
|
# If you change the minimal React Native version remember to update Compatibility Table in docs
|
|
56
|
-
minimalReactNativeVersion =
|
|
56
|
+
minimalReactNativeVersion = 78
|
|
57
57
|
if config[:react_native_minor_version] < minimalReactNativeVersion
|
|
58
58
|
raise "[Reanimated] Unsupported React Native version. Please use #{minimalReactNativeVersion} or newer."
|
|
59
59
|
end
|
|
@@ -7,13 +7,18 @@ export interface ViewDescriptorsSet {
|
|
|
7
7
|
shareableViewDescriptors: SharedValue<Descriptor[]>;
|
|
8
8
|
add: (item: Descriptor) => void;
|
|
9
9
|
remove: (viewTag: number) => void;
|
|
10
|
+
has: (viewTag: number) => boolean;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export function makeViewDescriptorsSet(): ViewDescriptorsSet {
|
|
13
14
|
const shareableViewDescriptors = makeMutable<Descriptor[]>([]);
|
|
15
|
+
const viewTags = new Set<number>();
|
|
16
|
+
|
|
14
17
|
const data: ViewDescriptorsSet = {
|
|
15
18
|
shareableViewDescriptors,
|
|
19
|
+
|
|
16
20
|
add: (item: Descriptor) => {
|
|
21
|
+
viewTags.add(item.tag as number);
|
|
17
22
|
shareableViewDescriptors.modify((descriptors) => {
|
|
18
23
|
'worklet';
|
|
19
24
|
const index = descriptors.findIndex(
|
|
@@ -29,6 +34,7 @@ export function makeViewDescriptorsSet(): ViewDescriptorsSet {
|
|
|
29
34
|
},
|
|
30
35
|
|
|
31
36
|
remove: (viewTag: number) => {
|
|
37
|
+
viewTags.delete(viewTag);
|
|
32
38
|
shareableViewDescriptors.modify((descriptors) => {
|
|
33
39
|
'worklet';
|
|
34
40
|
const index = descriptors.findIndex(
|
|
@@ -40,6 +46,9 @@ export function makeViewDescriptorsSet(): ViewDescriptorsSet {
|
|
|
40
46
|
return descriptors;
|
|
41
47
|
}, false);
|
|
42
48
|
},
|
|
49
|
+
|
|
50
|
+
has: (viewTag: number) => viewTags.has(viewTag),
|
|
43
51
|
};
|
|
52
|
+
|
|
44
53
|
return data;
|
|
45
54
|
}
|
package/src/animation/util.ts
CHANGED
|
@@ -284,6 +284,8 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
|
|
|
284
284
|
res.push(animation[i].current);
|
|
285
285
|
});
|
|
286
286
|
|
|
287
|
+
animation.unroundedCurrent = res;
|
|
288
|
+
|
|
287
289
|
// We need to clamp the res values to make sure they are in the correct RGBA range
|
|
288
290
|
clampRGBA(res as ParsedColorArray);
|
|
289
291
|
|
|
@@ -296,11 +298,11 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
|
|
|
296
298
|
animation: Animation<AnimationObject>,
|
|
297
299
|
timestamp: Timestamp
|
|
298
300
|
): boolean => {
|
|
299
|
-
const RGBACurrent = toLinearSpace(convertToRGBA(animation.current));
|
|
300
301
|
const res: Array<number> = [];
|
|
301
302
|
let finished = true;
|
|
302
|
-
|
|
303
|
-
|
|
303
|
+
// We must restore nonscale current to ever end the animation.
|
|
304
|
+
animation.current = animation.nonscaledCurrent;
|
|
305
|
+
tab.forEach((i) => {
|
|
304
306
|
const result = animation[i].onFrame(animation[i], timestamp);
|
|
305
307
|
// We really need to assign this value to result, instead of passing it directly - otherwise once "finished" is false, onFrame won't be called
|
|
306
308
|
finished = finished && result;
|
|
@@ -309,7 +311,7 @@ function decorateAnimation<T extends AnimationObject | StyleLayoutAnimation>(
|
|
|
309
311
|
|
|
310
312
|
// We need to clamp the res values to make sure they are in the correct RGBA range
|
|
311
313
|
clampRGBA(res as ParsedColorArray);
|
|
312
|
-
|
|
314
|
+
animation.nonscaledCurrent = res;
|
|
313
315
|
animation.current = rgbaArrayToRGBAColor(
|
|
314
316
|
toGammaSpace(res as ParsedColorArray)
|
|
315
317
|
);
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
*
|
|
15
15
|
* @param mode - Determines default reduce motion behavior globally in your
|
|
16
16
|
* application. Configured with {@link ReduceMotion} enum.
|
|
17
|
-
* @see https://docs.swmansion.com/react-native-reanimated/docs/
|
|
17
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/3.x/device/ReducedMotionConfig/
|
|
18
18
|
*/
|
|
19
19
|
export function ReducedMotionConfig({ mode }: { mode: ReduceMotion }) {
|
|
20
20
|
useEffect(() => {
|
|
@@ -108,7 +108,7 @@ export class NativeEventsManager implements INativeEventsManager {
|
|
|
108
108
|
// On the first render of a component, we may already receive a resolved view tag.
|
|
109
109
|
return this.#managedComponent.getComponentViewTag();
|
|
110
110
|
}
|
|
111
|
-
if (componentAnimatedRef
|
|
111
|
+
if (componentAnimatedRef?.__nativeTag || componentAnimatedRef?._nativeTag) {
|
|
112
112
|
/*
|
|
113
113
|
Fast path for native refs,
|
|
114
114
|
_nativeTag is used by Paper components,
|
|
@@ -30,6 +30,7 @@ import { ReanimatedError } from '../errors';
|
|
|
30
30
|
import { getShadowNodeWrapperFromRef } from '../fabricUtils';
|
|
31
31
|
import type { AnimateProps } from '../helperTypes';
|
|
32
32
|
import type { AnimatedStyleHandle } from '../hook/commonTypes';
|
|
33
|
+
import type { BaseAnimationBuilder } from '../layoutReanimation';
|
|
33
34
|
import { SharedTransition } from '../layoutReanimation';
|
|
34
35
|
import {
|
|
35
36
|
configureWebLayoutAnimations,
|
|
@@ -203,14 +204,18 @@ export function createAnimatedComponent(
|
|
|
203
204
|
saveSnapshot(this._componentDOMRef);
|
|
204
205
|
}
|
|
205
206
|
|
|
206
|
-
if (
|
|
207
|
-
!this.props.entering ||
|
|
208
|
-
getReducedMotionFromConfig(this.props.entering as CustomConfig)
|
|
209
|
-
) {
|
|
207
|
+
if (!this.props.entering) {
|
|
210
208
|
this._isFirstRender = false;
|
|
211
209
|
return;
|
|
212
210
|
}
|
|
213
211
|
|
|
212
|
+
if (getReducedMotionFromConfig(this.props.entering as CustomConfig)) {
|
|
213
|
+
this._isFirstRender = false;
|
|
214
|
+
|
|
215
|
+
(this.props.entering as BaseAnimationBuilder).callbackV?.(true);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
214
219
|
const skipEntering = this.context?.current;
|
|
215
220
|
|
|
216
221
|
if (!skipEntering) {
|
|
@@ -252,12 +257,11 @@ export function createAnimatedComponent(
|
|
|
252
257
|
|
|
253
258
|
const exiting = this.props.exiting;
|
|
254
259
|
|
|
255
|
-
if (
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
) {
|
|
260
|
+
if (IS_WEB && this._componentDOMRef && exiting) {
|
|
261
|
+
if (getReducedMotionFromConfig(exiting as CustomConfig)) {
|
|
262
|
+
(exiting as BaseAnimationBuilder).callbackV?.(true);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
261
265
|
addHTMLMutationObserver();
|
|
262
266
|
|
|
263
267
|
startWebLayoutAnimation(
|
|
@@ -383,6 +387,11 @@ export function createAnimatedComponent(
|
|
|
383
387
|
adaptViewConfig(viewConfig);
|
|
384
388
|
}
|
|
385
389
|
|
|
390
|
+
const newStyles = new Set<StyleProps>(styles);
|
|
391
|
+
|
|
392
|
+
const isStyleAttached = (style: StyleProps) =>
|
|
393
|
+
style.viewDescriptors.has(viewTag);
|
|
394
|
+
|
|
386
395
|
// remove old styles
|
|
387
396
|
if (prevStyles) {
|
|
388
397
|
// in most of the cases, views have only a single animated style and it remains unchanged
|
|
@@ -391,13 +400,15 @@ export function createAnimatedComponent(
|
|
|
391
400
|
prevStyles.length === 1 &&
|
|
392
401
|
styles[0] === prevStyles[0];
|
|
393
402
|
|
|
394
|
-
if (
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
403
|
+
if (hasOneSameStyle && isStyleAttached(prevStyles[0])) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// otherwise, remove each style that is not present in new styles
|
|
408
|
+
for (const prevStyle of prevStyles) {
|
|
409
|
+
const isPresent = styles.some((style) => style === prevStyle);
|
|
410
|
+
if (!isPresent && isStyleAttached(prevStyle)) {
|
|
411
|
+
prevStyle.viewDescriptors.remove(viewTag);
|
|
401
412
|
}
|
|
402
413
|
}
|
|
403
414
|
}
|
|
@@ -413,7 +424,7 @@ export function createAnimatedComponent(
|
|
|
413
424
|
}
|
|
414
425
|
}
|
|
415
426
|
|
|
416
|
-
|
|
427
|
+
newStyles.forEach((style) => {
|
|
417
428
|
style.viewDescriptors.add({
|
|
418
429
|
tag: viewTag,
|
|
419
430
|
name: viewName,
|
|
@@ -480,12 +491,12 @@ export function createAnimatedComponent(
|
|
|
480
491
|
saveSnapshot(this._componentDOMRef);
|
|
481
492
|
}
|
|
482
493
|
|
|
483
|
-
if (
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
494
|
+
if (IS_WEB && snapshot && this.props.layout) {
|
|
495
|
+
if (getReducedMotionFromConfig(this.props.layout as CustomConfig)) {
|
|
496
|
+
(this.props.layout as BaseAnimationBuilder).callbackV?.(true);
|
|
497
|
+
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
489
500
|
tryActivateLayoutTransition(
|
|
490
501
|
this.props,
|
|
491
502
|
this._componentDOMRef as ReanimatedHTMLElement,
|
package/src/helperTypes.ts
CHANGED
|
@@ -7,7 +7,7 @@ until time comes to refactor the code and get necessary types right.
|
|
|
7
7
|
This will not be easy though!
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type {
|
|
10
|
+
import type { StyleProp } from 'react-native';
|
|
11
11
|
|
|
12
12
|
import type {
|
|
13
13
|
AnimatedStyle,
|
|
@@ -20,6 +20,10 @@ import type { BaseAnimationBuilder } from './layoutReanimation/animationBuilder/
|
|
|
20
20
|
import type { ReanimatedKeyframe } from './layoutReanimation/animationBuilder/Keyframe';
|
|
21
21
|
import type { SharedTransition } from './layoutReanimation/sharedTransitions';
|
|
22
22
|
|
|
23
|
+
// RegisteredStyle was removed from React Native, provide a fallback type
|
|
24
|
+
// This is only used in a deprecated type definition
|
|
25
|
+
type RegisteredStyle<T> = number & { __registeredStyleBrand: T };
|
|
26
|
+
|
|
23
27
|
export type EntryOrExitLayoutType =
|
|
24
28
|
| BaseAnimationBuilder
|
|
25
29
|
| typeof BaseAnimationBuilder
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
import type { EasingFunctionFactory } from '../../Easing';
|
|
4
|
+
|
|
5
|
+
type BezierClosure = {
|
|
6
|
+
x1: number;
|
|
7
|
+
y1: number;
|
|
8
|
+
x2: number;
|
|
9
|
+
y2: number;
|
|
10
|
+
Bezier: () => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
3
13
|
// Those are the easings that can be implemented using Bezier curves.
|
|
4
14
|
// Others should be done as CSS animations
|
|
5
15
|
export const WebEasings = {
|
|
@@ -16,4 +26,26 @@ export function getEasingByName(easingName: WebEasingsNames) {
|
|
|
16
26
|
return `cubic-bezier(${WebEasings[easingName].toString()})`;
|
|
17
27
|
}
|
|
18
28
|
|
|
29
|
+
export function maybeGetBezierEasing(
|
|
30
|
+
easing: EasingFunctionFactory
|
|
31
|
+
): null | string {
|
|
32
|
+
if (!('factory' in easing)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const easingFactory = easing.factory;
|
|
37
|
+
|
|
38
|
+
if (!('__closure' in easingFactory)) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const closure = easingFactory.__closure as BezierClosure;
|
|
43
|
+
|
|
44
|
+
if (!('Bezier' in closure)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return `cubic-bezier(${closure.x1}, ${closure.y1}, ${closure.x2}, ${closure.y2})`;
|
|
49
|
+
}
|
|
50
|
+
|
|
19
51
|
export type WebEasingsNames = keyof typeof WebEasings;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
import type { EasingFunction } from '../../commonTypes';
|
|
4
|
+
import type { EasingFunctionFactory } from '../../Easing';
|
|
3
5
|
import type { WebEasingsNames } from './Easing.web';
|
|
4
6
|
import { WebEasings } from './Easing.web';
|
|
5
7
|
|
|
@@ -20,6 +22,7 @@ export interface ReanimatedWebTransformProperties {
|
|
|
20
22
|
export interface AnimationStyle {
|
|
21
23
|
opacity?: number;
|
|
22
24
|
transform?: ReanimatedWebTransformProperties[];
|
|
25
|
+
easing?: EasingFunction | EasingFunctionFactory;
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
export interface AnimationData {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
import { LayoutAnimationType, ReduceMotion } from '../../commonTypes';
|
|
4
|
+
import type { EasingFunctionFactory } from '../../Easing';
|
|
4
5
|
import { EasingNameSymbol } from '../../Easing';
|
|
5
6
|
import { logger } from '../../logger';
|
|
6
7
|
import type { ReanimatedHTMLElement } from '../../ReanimatedModule/js-reanimated';
|
|
@@ -15,13 +16,18 @@ import type {
|
|
|
15
16
|
AnimationConfig,
|
|
16
17
|
AnimationNames,
|
|
17
18
|
CustomConfig,
|
|
19
|
+
EasingType,
|
|
18
20
|
KeyframeDefinitions,
|
|
19
21
|
} from './config';
|
|
20
22
|
import { Animations, TransitionType } from './config';
|
|
21
23
|
import { TransitionGenerator } from './createAnimation';
|
|
22
24
|
import { scheduleAnimationCleanup } from './domUtils';
|
|
23
25
|
import type { WebEasingsNames } from './Easing.web';
|
|
24
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
getEasingByName,
|
|
28
|
+
maybeGetBezierEasing,
|
|
29
|
+
WebEasings,
|
|
30
|
+
} from './Easing.web';
|
|
25
31
|
import { prepareCurvedTransition } from './transition/Curved.web';
|
|
26
32
|
|
|
27
33
|
function getEasingFromConfig(config: CustomConfig): string {
|
|
@@ -29,15 +35,25 @@ function getEasingFromConfig(config: CustomConfig): string {
|
|
|
29
35
|
return getEasingByName('linear');
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
const easingName = config.easingV[EasingNameSymbol];
|
|
38
|
+
const easingName = (config.easingV as EasingType)[EasingNameSymbol];
|
|
33
39
|
|
|
34
|
-
if (
|
|
35
|
-
|
|
40
|
+
if (easingName in WebEasings) {
|
|
41
|
+
return getEasingByName(easingName as WebEasingsNames);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const bezierEasing = maybeGetBezierEasing(
|
|
45
|
+
config.easingV as EasingFunctionFactory
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (!bezierEasing) {
|
|
49
|
+
logger.warn(
|
|
50
|
+
`Selected easing is not currently supported on web. Using linear easing instead.`
|
|
51
|
+
);
|
|
36
52
|
|
|
37
53
|
return getEasingByName('linear');
|
|
38
54
|
}
|
|
39
55
|
|
|
40
|
-
return
|
|
56
|
+
return bezierEasing;
|
|
41
57
|
}
|
|
42
58
|
|
|
43
59
|
function getRandomDelay(maxDelay = 1000) {
|
|
@@ -173,27 +189,35 @@ export function setElementAnimation(
|
|
|
173
189
|
configureAnimation();
|
|
174
190
|
}
|
|
175
191
|
|
|
192
|
+
const maybeRemoveElement = () => {
|
|
193
|
+
if (element.reanimatedDummy && parent?.contains(element)) {
|
|
194
|
+
element.removedAfterAnimation = true;
|
|
195
|
+
parent.removeChild(element);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
let wasCallbackCalled = false;
|
|
200
|
+
const maybeCallCallback = (finished: boolean) => {
|
|
201
|
+
if (!wasCallbackCalled && animationConfig.callback) {
|
|
202
|
+
animationConfig.callback(finished);
|
|
203
|
+
wasCallbackCalled = true;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
176
207
|
element.onanimationend = () => {
|
|
177
208
|
if (shouldSavePosition) {
|
|
178
209
|
saveSnapshot(element);
|
|
179
210
|
}
|
|
180
211
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
parent.removeChild(element);
|
|
184
|
-
}
|
|
212
|
+
maybeRemoveElement();
|
|
213
|
+
maybeCallCallback(true);
|
|
185
214
|
|
|
186
|
-
animationConfig.callback?.(true);
|
|
187
215
|
element.removeEventListener('animationcancel', animationCancelHandler);
|
|
188
216
|
};
|
|
189
217
|
|
|
190
218
|
const animationCancelHandler = () => {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (parent?.contains(element)) {
|
|
194
|
-
element.removedAfterAnimation = true;
|
|
195
|
-
parent.removeChild(element);
|
|
196
|
-
}
|
|
219
|
+
maybeRemoveElement();
|
|
220
|
+
maybeCallCallback(false);
|
|
197
221
|
|
|
198
222
|
element.removeEventListener('animationcancel', animationCancelHandler);
|
|
199
223
|
};
|
|
@@ -212,6 +236,9 @@ export function setElementAnimation(
|
|
|
212
236
|
if (shouldSavePosition) {
|
|
213
237
|
setElementPosition(element, snapshots.get(element)!);
|
|
214
238
|
}
|
|
239
|
+
|
|
240
|
+
maybeRemoveElement();
|
|
241
|
+
maybeCallCallback(false);
|
|
215
242
|
});
|
|
216
243
|
}
|
|
217
244
|
}
|
|
@@ -301,6 +328,20 @@ export function handleExitingAnimation(
|
|
|
301
328
|
element.style.animationName = '';
|
|
302
329
|
dummy.style.animationName = '';
|
|
303
330
|
|
|
331
|
+
// Moving elements in DOM resets their scroll positions
|
|
332
|
+
// so we memorize them here and restore after
|
|
333
|
+
const scrollPositions = new Map<Element, { top: number; left: number }>();
|
|
334
|
+
const saveScrollPosition = (node: Element) => {
|
|
335
|
+
scrollPositions.set(node, {
|
|
336
|
+
top: node.scrollTop,
|
|
337
|
+
left: node.scrollLeft,
|
|
338
|
+
});
|
|
339
|
+
for (const child of Array.from(node.children)) {
|
|
340
|
+
saveScrollPosition(child);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
saveScrollPosition(element);
|
|
344
|
+
|
|
304
345
|
// After cloning the element, we want to move all children from original element to its clone. This is because original element
|
|
305
346
|
// will be unmounted, therefore when this code executes in child component, parent will be either empty or removed soon.
|
|
306
347
|
// Using element.cloneNode(true) doesn't solve the problem, because it creates copy of children and we won't be able to set their animations
|
|
@@ -312,6 +353,18 @@ export function handleExitingAnimation(
|
|
|
312
353
|
|
|
313
354
|
parent?.appendChild(dummy);
|
|
314
355
|
|
|
356
|
+
const restoreScrollPosition = (node: Element) => {
|
|
357
|
+
const scrollPosition = scrollPositions.get(node === dummy ? element : node);
|
|
358
|
+
if (scrollPosition) {
|
|
359
|
+
node.scrollTop = scrollPosition.top;
|
|
360
|
+
node.scrollLeft = scrollPosition.left;
|
|
361
|
+
}
|
|
362
|
+
for (const child of Array.from(node.children)) {
|
|
363
|
+
restoreScrollPosition(child);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
restoreScrollPosition(dummy);
|
|
367
|
+
|
|
315
368
|
const snapshot = snapshots.get(element)!;
|
|
316
369
|
|
|
317
370
|
const scrollOffsets = getElementScrollValue(element);
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
ReduceMotion,
|
|
5
5
|
StyleProps,
|
|
6
6
|
} from '../../commonTypes';
|
|
7
|
+
import type { EasingFunctionFactory } from '../../Easing';
|
|
7
8
|
import {
|
|
8
9
|
BounceIn,
|
|
9
10
|
BounceInData,
|
|
@@ -43,7 +44,10 @@ import type { AnimationData, AnimationStyle } from './animationParser';
|
|
|
43
44
|
|
|
44
45
|
export type AnimationCallback = ((finished: boolean) => void) | null;
|
|
45
46
|
|
|
46
|
-
export type KeyframeDefinitions = Record<
|
|
47
|
+
export type KeyframeDefinitions = Record<
|
|
48
|
+
`${number}` | 'from' | 'to',
|
|
49
|
+
AnimationStyle
|
|
50
|
+
>;
|
|
47
51
|
|
|
48
52
|
export type InitialValuesStyleProps = Omit<StyleProps, 'opacity'> & {
|
|
49
53
|
opacity?: number;
|
|
@@ -59,13 +63,13 @@ export interface AnimationConfig {
|
|
|
59
63
|
reversed: boolean;
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
interface EasingType {
|
|
66
|
+
export interface EasingType {
|
|
63
67
|
(): number;
|
|
64
68
|
[EasingNameSymbol: symbol]: string;
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
export interface CustomConfig {
|
|
68
|
-
easingV?: EasingType;
|
|
72
|
+
easingV?: EasingType | EasingFunctionFactory;
|
|
69
73
|
easingXV?: EasingType;
|
|
70
74
|
easingYV?: EasingType;
|
|
71
75
|
durationV?: number;
|
|
@@ -68,6 +68,21 @@ export function createCustomKeyFrameAnimation(
|
|
|
68
68
|
|
|
69
69
|
animationData.name = generateNextCustomKeyframeName();
|
|
70
70
|
|
|
71
|
+
// Move keyframe easings one keyframe up (our LA Keyframe definition is different
|
|
72
|
+
// from the CSS keyframes and expects easing to be present in the keyframe to which
|
|
73
|
+
// we animate instead of the keyframe we animate from)
|
|
74
|
+
const offsets = Object.keys(
|
|
75
|
+
keyframeDefinitions
|
|
76
|
+
) as (keyof KeyframeDefinitions)[];
|
|
77
|
+
|
|
78
|
+
for (let i = 1; i < offsets.length; i++) {
|
|
79
|
+
const style = keyframeDefinitions[offsets[i]];
|
|
80
|
+
if (style.easing) {
|
|
81
|
+
keyframeDefinitions[offsets[i - 1]].easing = style.easing;
|
|
82
|
+
delete style.easing;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
71
86
|
const parsedKeyframe = convertAnimationObjectToKeyframes(animationData);
|
|
72
87
|
|
|
73
88
|
insertWebAnimation(animationData.name, parsedKeyframe);
|
|
@@ -120,7 +120,7 @@ function removeWebAnimation(
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
const timeoutScale =
|
|
123
|
+
const timeoutScale = 5; // We use this value to enlarge timeout duration. It can prove useful if animation lags.
|
|
124
124
|
const frameDurationMs = 16; // Just an approximation.
|
|
125
125
|
const minimumFrames = 10;
|
|
126
126
|
|
|
@@ -44,8 +44,21 @@ function dispatchCommandFabric(
|
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const shadowNodeWrapper = animatedRef()
|
|
48
|
-
|
|
47
|
+
const shadowNodeWrapper = animatedRef();
|
|
48
|
+
|
|
49
|
+
// This prevents crashes if ref has not been set yet
|
|
50
|
+
if (!shadowNodeWrapper) {
|
|
51
|
+
logger.warn(
|
|
52
|
+
`Tried to dispatch command "${commandName}" with an uninitialized ref. Make sure to pass the animated ref to the component before using it.`
|
|
53
|
+
);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
global._dispatchCommandFabric!(
|
|
58
|
+
shadowNodeWrapper as ShadowNodeWrapper,
|
|
59
|
+
commandName,
|
|
60
|
+
args
|
|
61
|
+
);
|
|
49
62
|
}
|
|
50
63
|
|
|
51
64
|
function dispatchCommandPaper(
|
|
@@ -59,6 +72,14 @@ function dispatchCommandPaper(
|
|
|
59
72
|
}
|
|
60
73
|
|
|
61
74
|
const viewTag = animatedRef() as number;
|
|
75
|
+
|
|
76
|
+
if (viewTag < 0) {
|
|
77
|
+
logger.warn(
|
|
78
|
+
`Tried to dispatch command "${commandName}" with an uninitialized ref. Make sure to pass the animated ref to the component before using it.`
|
|
79
|
+
);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
62
83
|
global._dispatchCommandPaper!(viewTag, commandName, args);
|
|
63
84
|
}
|
|
64
85
|
|