react-native-reanimated 3.0.0-rc.9 → 3.0.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.
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.cpp +30 -12
- package/Common/cpp/AnimatedSensor/AnimatedSensorModule.h +2 -0
- package/Common/cpp/Fabric/FabricUtils.cpp +3 -107
- package/Common/cpp/Fabric/FabricUtils.h +3 -24
- package/Common/cpp/Fabric/ReanimatedUIManagerBinding.cpp +54 -37
- package/Common/cpp/LayoutAnimations/LayoutAnimationType.h +8 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +81 -26
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +20 -3
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +105 -109
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +19 -12
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +15 -7
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +6 -2
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.cpp +20 -1
- package/Common/cpp/ReanimatedRuntime/ReanimatedHermesRuntime.h +9 -0
- package/Common/cpp/ReanimatedRuntime/ReanimatedRuntime.cpp +5 -1
- package/Common/cpp/Registries/EventHandlerRegistry.cpp +8 -34
- package/Common/cpp/Registries/EventHandlerRegistry.h +7 -13
- package/Common/cpp/SharedItems/Shareables.cpp +9 -63
- package/Common/cpp/SharedItems/Shareables.h +77 -72
- package/Common/cpp/Tools/CollectionUtils.h +14 -0
- package/Common/cpp/Tools/JsiUtils.cpp +26 -0
- package/Common/cpp/Tools/JsiUtils.h +176 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +5 -5
- package/Common/cpp/Tools/ReanimatedVersion.cpp +17 -0
- package/Common/cpp/Tools/ReanimatedVersion.h +11 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +49 -230
- package/Common/cpp/Tools/RuntimeDecorator.h +0 -2
- package/Common/cpp/Tools/WorkletEventHandler.cpp +3 -2
- package/Common/cpp/Tools/WorkletEventHandler.h +14 -6
- package/RNReanimated.podspec +2 -1
- package/android/CMakeLists.txt +188 -181
- package/android/build.gradle +362 -311
- package/android/proguard-rules.pro +2 -0
- package/android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java +63 -295
- package/android/src/main/cpp/LayoutAnimations.cpp +35 -5
- package/android/src/main/cpp/LayoutAnimations.h +23 -6
- package/android/src/main/cpp/NativeProxy.cpp +143 -98
- package/android/src/main/cpp/NativeProxy.h +22 -28
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +5 -4
- package/android/src/main/java/com/swmansion/reanimated/Utils.java +7 -1
- package/android/src/main/java/com/swmansion/reanimated/keyboardObserver/ReanimatedKeyboardEventListener.java +10 -3
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +218 -35
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/LayoutAnimations.java +43 -17
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/NativeMethodsHolder.java +6 -2
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedElement.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +610 -0
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/Snapshot.java +93 -23
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/AnimationFrameCallback.java +19 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/EventHandler.java +35 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/KeyboardEventDataUpdater.java +16 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +206 -0
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/SensorSetter.java +17 -0
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +9 -3
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorContainer.java +3 -4
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.java +31 -7
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +90 -307
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +16 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +63 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +271 -0
- package/android/src/reactNativeVersionPatch/nativeHierarchyManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +76 -20
- package/ios/LayoutReanimation/REAAnimationsManager.h +28 -4
- package/ios/LayoutReanimation/REAAnimationsManager.m +216 -61
- package/ios/LayoutReanimation/REAFrame.h +10 -0
- package/ios/LayoutReanimation/REAFrame.m +15 -0
- package/ios/LayoutReanimation/REAScreensHelper.h +19 -0
- package/ios/LayoutReanimation/REAScreensHelper.m +106 -0
- package/ios/LayoutReanimation/REASharedElement.h +15 -0
- package/ios/LayoutReanimation/REASharedElement.m +16 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.h +17 -0
- package/ios/LayoutReanimation/REASharedTransitionManager.m +632 -0
- package/ios/LayoutReanimation/REASnapshot.h +1 -0
- package/ios/LayoutReanimation/REASnapshot.m +96 -11
- package/ios/LayoutReanimation/REAUIManager.mm +64 -17
- package/ios/REAModule.mm +2 -7
- package/ios/REANodesManager.mm +1 -21
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +72 -36
- package/ios/native/NativeProxy.mm +75 -114
- package/ios/native/REAInitializer.mm +2 -7
- package/ios/native/REAJSIUtils.h +60 -2
- package/ios/sensor/ReanimatedSensor.h +6 -2
- package/ios/sensor/ReanimatedSensor.m +43 -7
- package/ios/sensor/ReanimatedSensorContainer.h +4 -1
- package/ios/sensor/ReanimatedSensorContainer.m +8 -2
- package/lib/commonjs/createAnimatedComponent.js +232 -28
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/reanimated2/Colors.js +43 -22
- package/lib/commonjs/reanimated2/Colors.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +16 -33
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js +17 -15
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +33 -1
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +33 -14
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/commonjs/reanimated2/globals.d.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/index.js +0 -6
- package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +13 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +89 -16
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +43 -40
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js +13 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js +18 -65
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/index.js +13 -0
- package/lib/commonjs/reanimated2/index.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +71 -32
- package/lib/commonjs/reanimated2/initializers.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolateColor.js +96 -19
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +103 -13
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +22 -0
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/commonjs/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/commonjs/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +0 -2
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +0 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +11 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +8 -0
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +17 -9
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -14
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -15
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +13 -0
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +94 -0
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/commonjs/reanimated2/mappers.js +18 -6
- package/lib/commonjs/reanimated2/mappers.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +20 -1
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +4 -2
- package/lib/commonjs/reanimated2/mutables.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +42 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +15 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/commonjs/reanimated2/pluginUtils.js +11 -0
- package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -0
- package/lib/commonjs/reanimated2/shareables.js +36 -15
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +114 -4
- package/lib/commonjs/reanimated2/threads.js.map +1 -1
- package/lib/commonjs/reanimated2/utils.js +7 -0
- package/lib/commonjs/reanimated2/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/valueSetter.js +1 -3
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +229 -29
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +35 -19
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -32
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +5 -1
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +17 -16
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +29 -0
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/core.js +32 -7
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +2 -2
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +5 -2
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +12 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +2 -2
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +88 -13
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +46 -43
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +12 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +2 -2
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +17 -60
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js +1 -0
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +72 -33
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +96 -19
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +1 -1
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +103 -13
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +21 -0
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/WebSensor.js +2 -0
- package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -0
- package/lib/module/reanimated2/js-reanimated/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +0 -2
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +0 -1
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +9 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +15 -8
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +8 -12
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +8 -13
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +16 -21
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js +1 -0
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +82 -0
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -0
- package/lib/module/reanimated2/mappers.js +16 -6
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +20 -1
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +4 -2
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.js +35 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.js.map +1 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js +8 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -0
- package/lib/module/reanimated2/pluginUtils.js +4 -0
- package/lib/module/reanimated2/pluginUtils.js.map +1 -0
- package/lib/module/reanimated2/shareables.js +36 -12
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +105 -4
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/utils.js +5 -0
- package/lib/module/reanimated2/utils.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +1 -2
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/package.json +10 -10
- package/{plugin.js → plugin/index.js} +128 -249
- package/react-native-reanimated.d.ts +57 -10
- package/scripts/reanimated_utils.rb +15 -2
- package/src/createAnimatedComponent.tsx +238 -28
- package/src/reanimated2/Colors.ts +38 -11
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +52 -39
- package/src/reanimated2/animation/styleAnimation.ts +8 -1
- package/src/reanimated2/animation/util.ts +29 -16
- package/src/reanimated2/commonTypes.ts +28 -1
- package/src/reanimated2/core.ts +42 -9
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +2 -2
- package/src/reanimated2/globals.d.ts +12 -15
- package/src/reanimated2/hook/index.ts +1 -1
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +10 -4
- package/src/reanimated2/hook/useAnimatedReaction.ts +12 -5
- package/src/reanimated2/hook/useAnimatedRef.ts +1 -4
- package/src/reanimated2/hook/useAnimatedSensor.ts +88 -11
- package/src/reanimated2/hook/useAnimatedStyle.ts +44 -36
- package/src/reanimated2/hook/useDerivedValue.ts +8 -1
- package/src/reanimated2/hook/useScrollViewOffset.ts +2 -2
- package/src/reanimated2/hook/utils.ts +15 -61
- package/src/reanimated2/index.ts +1 -0
- package/src/reanimated2/initializers.ts +76 -35
- package/src/reanimated2/interpolateColor.ts +104 -20
- package/src/reanimated2/jestUtils.ts +1 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +98 -15
- package/src/reanimated2/js-reanimated/Mapper.ts +32 -0
- package/src/reanimated2/js-reanimated/WebSensor.ts +34 -0
- package/src/reanimated2/js-reanimated/commonTypes.ts +0 -1
- package/src/reanimated2/js-reanimated/global.ts +0 -1
- package/src/reanimated2/js-reanimated/index.ts +0 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +13 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/animationsManager.ts +17 -9
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +16 -19
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +14 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +21 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +32 -11
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +36 -19
- package/src/reanimated2/layoutReanimation/index.ts +1 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/index.ts +87 -0
- package/src/reanimated2/mappers.ts +17 -6
- package/src/reanimated2/mock.ts +24 -1
- package/src/reanimated2/mutables.ts +2 -0
- package/src/reanimated2/platform-specific/checkVersion.ts +39 -0
- package/src/reanimated2/platform-specific/checkVersion.web.ts +6 -0
- package/src/reanimated2/pluginUtils.ts +8 -0
- package/src/reanimated2/shareables.ts +45 -16
- package/src/reanimated2/threads.ts +103 -1
- package/src/reanimated2/utils.ts +6 -0
- package/src/reanimated2/valueSetter.ts +1 -2
- package/lib/commonjs/reanimated2/time.js +0 -55
- package/lib/commonjs/reanimated2/time.js.map +0 -1
- package/lib/module/reanimated2/time.js +0 -37
- package/lib/module/reanimated2/time.js.map +0 -1
- package/src/reanimated2/time.ts +0 -30
- /package/android/src/{main/java → reactNativeVersionPatch/ReanimatedUIManager/70}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -0
|
@@ -19,29 +19,96 @@ export const Extrapolate = {
|
|
|
19
19
|
IDENTITY: 'identity',
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
export type InterpolationOptions = {
|
|
23
|
+
gamma?: number;
|
|
24
|
+
useCorrectedHSVInterpolation?: boolean;
|
|
25
|
+
};
|
|
26
|
+
|
|
22
27
|
const interpolateColorsHSV = (
|
|
23
28
|
value: number,
|
|
24
29
|
inputRange: readonly number[],
|
|
25
|
-
colors: InterpolateHSV
|
|
30
|
+
colors: InterpolateHSV,
|
|
31
|
+
options: InterpolationOptions
|
|
26
32
|
) => {
|
|
27
33
|
'worklet';
|
|
28
|
-
|
|
34
|
+
let h = 0;
|
|
35
|
+
const { useCorrectedHSVInterpolation = true } = options;
|
|
36
|
+
if (useCorrectedHSVInterpolation) {
|
|
37
|
+
// if the difference between hues in a range is > 180 deg
|
|
38
|
+
// then move the hue at the right end of the range +/- 360 deg
|
|
39
|
+
// and add the next point in the original place + 0.00001 with original hue
|
|
40
|
+
// to not break the next range
|
|
41
|
+
const correctedInputRange = [inputRange[0]];
|
|
42
|
+
const originalH = colors.h;
|
|
43
|
+
const correctedH = [originalH[0]];
|
|
44
|
+
|
|
45
|
+
for (let i = 1; i < originalH.length; ++i) {
|
|
46
|
+
const d = originalH[i] - originalH[i - 1];
|
|
47
|
+
if (originalH[i] > originalH[i - 1] && d > 0.5) {
|
|
48
|
+
correctedInputRange.push(inputRange[i]);
|
|
49
|
+
correctedInputRange.push(inputRange[i] + 0.00001);
|
|
50
|
+
correctedH.push(originalH[i] - 1);
|
|
51
|
+
correctedH.push(originalH[i]);
|
|
52
|
+
} else if (originalH[i] < originalH[i - 1] && d < -0.5) {
|
|
53
|
+
correctedInputRange.push(inputRange[i]);
|
|
54
|
+
correctedInputRange.push(inputRange[i] + 0.00001);
|
|
55
|
+
correctedH.push(originalH[i] + 1);
|
|
56
|
+
correctedH.push(originalH[i]);
|
|
57
|
+
} else {
|
|
58
|
+
correctedInputRange.push(inputRange[i]);
|
|
59
|
+
correctedH.push(originalH[i]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
h =
|
|
63
|
+
(interpolate(value, correctedInputRange, correctedH, Extrapolate.CLAMP) +
|
|
64
|
+
1) %
|
|
65
|
+
1;
|
|
66
|
+
} else {
|
|
67
|
+
h = interpolate(value, inputRange, colors.h, Extrapolate.CLAMP);
|
|
68
|
+
}
|
|
29
69
|
const s = interpolate(value, inputRange, colors.s, Extrapolate.CLAMP);
|
|
30
70
|
const v = interpolate(value, inputRange, colors.v, Extrapolate.CLAMP);
|
|
31
|
-
|
|
71
|
+
const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);
|
|
72
|
+
return hsvToColor(h, s, v, a);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const toLinearSpace = (x: number[], gamma: number): number[] => {
|
|
76
|
+
'worklet';
|
|
77
|
+
return x.map((v) => Math.pow(v / 255, gamma));
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const toGammaSpace = (x: number, gamma: number): number => {
|
|
81
|
+
'worklet';
|
|
82
|
+
return Math.round(Math.pow(x, 1 / gamma) * 255);
|
|
32
83
|
};
|
|
33
84
|
|
|
34
85
|
const interpolateColorsRGB = (
|
|
35
86
|
value: number,
|
|
36
87
|
inputRange: readonly number[],
|
|
37
|
-
colors: InterpolateRGB
|
|
88
|
+
colors: InterpolateRGB,
|
|
89
|
+
options: InterpolationOptions
|
|
38
90
|
) => {
|
|
39
91
|
'worklet';
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
92
|
+
const { gamma = 2.2 } = options;
|
|
93
|
+
let { r: outputR, g: outputG, b: outputB } = colors;
|
|
94
|
+
if (gamma !== 1) {
|
|
95
|
+
outputR = toLinearSpace(outputR, gamma);
|
|
96
|
+
outputG = toLinearSpace(outputG, gamma);
|
|
97
|
+
outputB = toLinearSpace(outputB, gamma);
|
|
98
|
+
}
|
|
99
|
+
const r = interpolate(value, inputRange, outputR, Extrapolate.CLAMP);
|
|
100
|
+
const g = interpolate(value, inputRange, outputG, Extrapolate.CLAMP);
|
|
101
|
+
const b = interpolate(value, inputRange, outputB, Extrapolate.CLAMP);
|
|
43
102
|
const a = interpolate(value, inputRange, colors.a, Extrapolate.CLAMP);
|
|
44
|
-
|
|
103
|
+
if (gamma === 1) {
|
|
104
|
+
return rgbaColor(r, g, b, a);
|
|
105
|
+
}
|
|
106
|
+
return rgbaColor(
|
|
107
|
+
toGammaSpace(r, gamma),
|
|
108
|
+
toGammaSpace(g, gamma),
|
|
109
|
+
toGammaSpace(b, gamma),
|
|
110
|
+
a
|
|
111
|
+
);
|
|
45
112
|
};
|
|
46
113
|
|
|
47
114
|
interface InterpolateRGB {
|
|
@@ -78,6 +145,7 @@ interface InterpolateHSV {
|
|
|
78
145
|
h: number[];
|
|
79
146
|
s: number[];
|
|
80
147
|
v: number[];
|
|
148
|
+
a: number[];
|
|
81
149
|
}
|
|
82
150
|
|
|
83
151
|
const getInterpolateHSV = (
|
|
@@ -87,36 +155,47 @@ const getInterpolateHSV = (
|
|
|
87
155
|
const h = [];
|
|
88
156
|
const s = [];
|
|
89
157
|
const v = [];
|
|
158
|
+
const a = [];
|
|
90
159
|
for (let i = 0; i < colors.length; ++i) {
|
|
91
160
|
const color = colors[i];
|
|
92
|
-
const processedColor =
|
|
93
|
-
if (processedColor) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
161
|
+
const processedColor = processColor(color) as any;
|
|
162
|
+
if (typeof processedColor === 'number') {
|
|
163
|
+
const processedHSVColor = RGBtoHSV(
|
|
164
|
+
red(processedColor),
|
|
165
|
+
green(processedColor),
|
|
166
|
+
blue(processedColor)
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
h.push(processedHSVColor.h);
|
|
170
|
+
s.push(processedHSVColor.s);
|
|
171
|
+
v.push(processedHSVColor.v);
|
|
172
|
+
a.push(opacity(processedColor));
|
|
97
173
|
}
|
|
98
174
|
}
|
|
99
|
-
return { h, s, v };
|
|
175
|
+
return { h, s, v, a };
|
|
100
176
|
};
|
|
101
177
|
|
|
102
178
|
export const interpolateColor = (
|
|
103
179
|
value: number,
|
|
104
180
|
inputRange: readonly number[],
|
|
105
181
|
outputRange: readonly (string | number)[],
|
|
106
|
-
colorSpace: 'RGB' | 'HSV' = 'RGB'
|
|
182
|
+
colorSpace: 'RGB' | 'HSV' = 'RGB',
|
|
183
|
+
options: InterpolationOptions = {}
|
|
107
184
|
): string | number => {
|
|
108
185
|
'worklet';
|
|
109
186
|
if (colorSpace === 'HSV') {
|
|
110
187
|
return interpolateColorsHSV(
|
|
111
188
|
value,
|
|
112
189
|
inputRange,
|
|
113
|
-
getInterpolateHSV(outputRange)
|
|
190
|
+
getInterpolateHSV(outputRange),
|
|
191
|
+
options
|
|
114
192
|
);
|
|
115
193
|
} else if (colorSpace === 'RGB') {
|
|
116
194
|
return interpolateColorsRGB(
|
|
117
195
|
value,
|
|
118
196
|
inputRange,
|
|
119
|
-
getInterpolateRGB(outputRange)
|
|
197
|
+
getInterpolateRGB(outputRange),
|
|
198
|
+
options
|
|
120
199
|
);
|
|
121
200
|
}
|
|
122
201
|
throw new Error(
|
|
@@ -134,18 +213,21 @@ export interface InterpolateConfig {
|
|
|
134
213
|
outputRange: readonly (string | number)[];
|
|
135
214
|
colorSpace: ColorSpace;
|
|
136
215
|
cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;
|
|
216
|
+
options: InterpolationOptions;
|
|
137
217
|
}
|
|
138
218
|
|
|
139
219
|
export function useInterpolateConfig(
|
|
140
220
|
inputRange: readonly number[],
|
|
141
221
|
outputRange: readonly (string | number)[],
|
|
142
|
-
colorSpace = ColorSpace.RGB
|
|
222
|
+
colorSpace = ColorSpace.RGB,
|
|
223
|
+
options: InterpolationOptions = {}
|
|
143
224
|
): SharedValue<InterpolateConfig> {
|
|
144
225
|
return useSharedValue<InterpolateConfig>({
|
|
145
226
|
inputRange,
|
|
146
227
|
outputRange,
|
|
147
228
|
colorSpace,
|
|
148
229
|
cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),
|
|
230
|
+
options,
|
|
149
231
|
});
|
|
150
232
|
}
|
|
151
233
|
|
|
@@ -163,7 +245,8 @@ export const interpolateSharableColor = (
|
|
|
163
245
|
return interpolateColorsRGB(
|
|
164
246
|
value,
|
|
165
247
|
interpolateConfig.value.inputRange,
|
|
166
|
-
colors as InterpolateRGB
|
|
248
|
+
colors as InterpolateRGB,
|
|
249
|
+
interpolateConfig.value.options
|
|
167
250
|
);
|
|
168
251
|
} else if (interpolateConfig.value.colorSpace === ColorSpace.HSV) {
|
|
169
252
|
if (!colors) {
|
|
@@ -173,7 +256,8 @@ export const interpolateSharableColor = (
|
|
|
173
256
|
return interpolateColorsHSV(
|
|
174
257
|
value,
|
|
175
258
|
interpolateConfig.value.inputRange,
|
|
176
|
-
colors as InterpolateHSV
|
|
259
|
+
colors as InterpolateHSV,
|
|
260
|
+
interpolateConfig.value.options
|
|
177
261
|
);
|
|
178
262
|
}
|
|
179
263
|
throw new Error(
|
|
@@ -149,7 +149,7 @@ const afterTest = () => {
|
|
|
149
149
|
|
|
150
150
|
export const withReanimatedTimer = (animationTest) => {
|
|
151
151
|
console.warn(
|
|
152
|
-
'This method is deprecated, you
|
|
152
|
+
'This method is deprecated, you should define your own before and after test hooks to enable jest.useFakeTimers(). Check out the documentation for details on testing'
|
|
153
153
|
);
|
|
154
154
|
beforeTest();
|
|
155
155
|
animationTest();
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { NativeReanimated } from '../NativeReanimated/NativeReanimated';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
SensorType,
|
|
4
|
+
ShareableRef,
|
|
5
|
+
Value3D,
|
|
6
|
+
ValueRotation,
|
|
7
|
+
} from '../commonTypes';
|
|
8
|
+
import { WebSensor } from './WebSensor';
|
|
4
9
|
|
|
5
10
|
export default class JSReanimated extends NativeReanimated {
|
|
11
|
+
nextSensorId = 0;
|
|
12
|
+
sensors = new Map<number, WebSensor>();
|
|
13
|
+
|
|
6
14
|
constructor() {
|
|
7
15
|
super(false);
|
|
8
|
-
if (isJest()) {
|
|
9
|
-
// on node < 16 jest have problems mocking performance.now method which
|
|
10
|
-
// results in the tests failing, since date precision isn't that important
|
|
11
|
-
// for tests, we use Date.now instead
|
|
12
|
-
this.getTimestamp = () => Date.now();
|
|
13
|
-
} else {
|
|
14
|
-
this.getTimestamp = () => window.performance.now();
|
|
15
|
-
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
makeShareableClone<T>(value: T): ShareableRef<T> {
|
|
@@ -52,13 +52,62 @@ export default class JSReanimated extends NativeReanimated {
|
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
registerSensor(
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
registerSensor(
|
|
56
|
+
sensorType: SensorType,
|
|
57
|
+
interval: number,
|
|
58
|
+
iosReferenceFrame: number,
|
|
59
|
+
eventHandler: (data: Value3D | ValueRotation) => void
|
|
60
|
+
): number {
|
|
61
|
+
if (!(this.getSensorName(sensorType) in window)) {
|
|
62
|
+
return -1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const sensor: WebSensor = this.initializeSensor(sensorType, interval);
|
|
66
|
+
let callback;
|
|
67
|
+
if (sensorType === SensorType.ROTATION) {
|
|
68
|
+
callback = () => {
|
|
69
|
+
const [qw, qx, qy, qz] = sensor.quaternion;
|
|
70
|
+
|
|
71
|
+
// reference: https://stackoverflow.com/questions/5782658/extracting-yaw-from-a-quaternion
|
|
72
|
+
const yaw = Math.atan2(
|
|
73
|
+
2.0 * (qy * qz + qw * qx),
|
|
74
|
+
qw * qw - qx * qx - qy * qy + qz * qz
|
|
75
|
+
);
|
|
76
|
+
const pitch = Math.sin(-2.0 * (qx * qz - qw * qy));
|
|
77
|
+
const roll = Math.atan2(
|
|
78
|
+
2.0 * (qx * qy + qw * qz),
|
|
79
|
+
qw * qw + qx * qx - qy * qy - qz * qz
|
|
80
|
+
);
|
|
81
|
+
eventHandler({
|
|
82
|
+
qw,
|
|
83
|
+
qx,
|
|
84
|
+
qy,
|
|
85
|
+
qz,
|
|
86
|
+
yaw,
|
|
87
|
+
pitch,
|
|
88
|
+
roll,
|
|
89
|
+
interfaceOrientation: 0,
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
} else {
|
|
93
|
+
callback = () => {
|
|
94
|
+
const { x, y, z } = sensor;
|
|
95
|
+
eventHandler({ x, y, z, interfaceOrientation: 0 });
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
sensor.addEventListener('reading', callback);
|
|
99
|
+
sensor.start();
|
|
100
|
+
|
|
101
|
+
this.sensors.set(this.nextSensorId, sensor);
|
|
102
|
+
return this.nextSensorId++;
|
|
58
103
|
}
|
|
59
104
|
|
|
60
|
-
unregisterSensor(): void {
|
|
61
|
-
|
|
105
|
+
unregisterSensor(id: number): void {
|
|
106
|
+
const sensor: WebSensor | undefined = this.sensors.get(id);
|
|
107
|
+
if (sensor !== undefined) {
|
|
108
|
+
sensor.stop();
|
|
109
|
+
this.sensors.delete(id);
|
|
110
|
+
}
|
|
62
111
|
}
|
|
63
112
|
|
|
64
113
|
subscribeForKeyboardEvents(_: ShareableRef<number>): number {
|
|
@@ -71,4 +120,38 @@ export default class JSReanimated extends NativeReanimated {
|
|
|
71
120
|
unsubscribeFromKeyboardEvents(_: number): void {
|
|
72
121
|
// noop
|
|
73
122
|
}
|
|
123
|
+
|
|
124
|
+
initializeSensor(sensorType: SensorType, interval: number): WebSensor {
|
|
125
|
+
const config =
|
|
126
|
+
interval <= 0
|
|
127
|
+
? { referenceFrame: 'device' }
|
|
128
|
+
: { frequency: 1000 / interval };
|
|
129
|
+
switch (sensorType) {
|
|
130
|
+
case SensorType.ACCELEROMETER:
|
|
131
|
+
return new window.Accelerometer(config);
|
|
132
|
+
case SensorType.GYROSCOPE:
|
|
133
|
+
return new window.Gyroscope(config);
|
|
134
|
+
case SensorType.GRAVITY:
|
|
135
|
+
return new window.GravitySensor(config);
|
|
136
|
+
case SensorType.MAGNETIC_FIELD:
|
|
137
|
+
return new window.Magnetometer(config);
|
|
138
|
+
case SensorType.ROTATION:
|
|
139
|
+
return new window.AbsoluteOrientationSensor(config);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
getSensorName(sensorType: SensorType): string {
|
|
144
|
+
switch (sensorType) {
|
|
145
|
+
case SensorType.ACCELEROMETER:
|
|
146
|
+
return 'Accelerometer';
|
|
147
|
+
case SensorType.GRAVITY:
|
|
148
|
+
return 'GravitySensor';
|
|
149
|
+
case SensorType.GYROSCOPE:
|
|
150
|
+
return 'Gyroscope';
|
|
151
|
+
case SensorType.MAGNETIC_FIELD:
|
|
152
|
+
return 'Magnetometer';
|
|
153
|
+
case SensorType.ROTATION:
|
|
154
|
+
return 'AbsoluteOrientationSensor';
|
|
155
|
+
}
|
|
156
|
+
}
|
|
74
157
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NestedObjectValues } from '../commonTypes';
|
|
2
|
+
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
2
3
|
import { JSReanimated } from './commonTypes';
|
|
3
4
|
import MutableValue from './MutableValue';
|
|
4
5
|
|
|
@@ -49,6 +50,9 @@ export default class Mapper<T> {
|
|
|
49
50
|
res.push(value);
|
|
50
51
|
} else if (Array.isArray(value)) {
|
|
51
52
|
value.forEach((v) => extractMutables(v));
|
|
53
|
+
} else if (isWebDomElement(value)) {
|
|
54
|
+
// do nothing on dom elements
|
|
55
|
+
// without this check, we get a "Maximum call size exceeded error"
|
|
52
56
|
} else if (typeof value === 'object') {
|
|
53
57
|
Object.keys(value).forEach((key) => {
|
|
54
58
|
extractMutables(value[key]);
|
|
@@ -60,3 +64,31 @@ export default class Mapper<T> {
|
|
|
60
64
|
return res;
|
|
61
65
|
}
|
|
62
66
|
}
|
|
67
|
+
|
|
68
|
+
function isWebDomElement(value: any) {
|
|
69
|
+
if (!shouldBeUseWeb()) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// https://stackoverflow.com/a/384380/7869175
|
|
74
|
+
function isWebNode(o: any) {
|
|
75
|
+
return typeof Node === 'object'
|
|
76
|
+
? o instanceof Node
|
|
77
|
+
: o &&
|
|
78
|
+
typeof o === 'object' &&
|
|
79
|
+
typeof o.nodeType === 'number' &&
|
|
80
|
+
typeof o.nodeName === 'string';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function isWebElement(o: any) {
|
|
84
|
+
return typeof HTMLElement === 'object'
|
|
85
|
+
? o instanceof HTMLElement // DOM2
|
|
86
|
+
: o &&
|
|
87
|
+
typeof o === 'object' &&
|
|
88
|
+
o !== null &&
|
|
89
|
+
o.nodeType === 1 &&
|
|
90
|
+
typeof o.nodeName === 'string';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return isWebNode(value) || isWebElement(value);
|
|
94
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare class WebSensor {
|
|
2
|
+
start: () => void;
|
|
3
|
+
stop: () => void;
|
|
4
|
+
addEventListener: (eventType: string, eventHandler: () => void) => void;
|
|
5
|
+
quaternion: [number, number, number, number];
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
z: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type configOptions =
|
|
12
|
+
| {
|
|
13
|
+
referenceFrame: string;
|
|
14
|
+
frequency?: undefined;
|
|
15
|
+
}
|
|
16
|
+
| {
|
|
17
|
+
frequency: number;
|
|
18
|
+
referenceFrame?: undefined;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
interface Constructable<T> {
|
|
22
|
+
new (config: configOptions): T;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare global {
|
|
26
|
+
interface Window {
|
|
27
|
+
Accelerometer: Constructable<WebSensor>;
|
|
28
|
+
GravitySensor: Constructable<WebSensor>;
|
|
29
|
+
Gyroscope: Constructable<WebSensor>;
|
|
30
|
+
Magnetometer: Constructable<WebSensor>;
|
|
31
|
+
AbsoluteOrientationSensor: Constructable<WebSensor>;
|
|
32
|
+
Sensor: Constructable<WebSensor>;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -32,7 +32,6 @@ export interface JSReanimated {
|
|
|
32
32
|
_frames: ((timestamp: Timestamp) => void)[];
|
|
33
33
|
timeProvider: { now: () => number };
|
|
34
34
|
pushFrame(frame: (timestamp: Timestamp) => void): void;
|
|
35
|
-
getTimestamp(): number;
|
|
36
35
|
maybeRequestRender(): void;
|
|
37
36
|
_onRender(timestampMs: number): void;
|
|
38
37
|
installCoreFunctions(valueSetter: <T>(value: T) => void): void;
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { shouldBeUseWeb } from '../PlatformChecker';
|
|
4
4
|
const initializeGlobalsForWeb = () => {
|
|
5
5
|
if (shouldBeUseWeb()) {
|
|
6
|
-
global._frameTimestamp = null;
|
|
7
6
|
global._measure = () => {
|
|
8
7
|
console.warn(
|
|
9
8
|
"[Reanimated] You can't use `measure` with Chrome Debugger or with web version"
|
|
@@ -21,6 +21,8 @@ export interface EntryAnimationsValues {
|
|
|
21
21
|
targetHeight: number;
|
|
22
22
|
targetGlobalOriginX: number;
|
|
23
23
|
targetGlobalOriginY: number;
|
|
24
|
+
windowWidth: number;
|
|
25
|
+
windowHeight: number;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export interface ExitAnimationsValues {
|
|
@@ -30,6 +32,8 @@ export interface ExitAnimationsValues {
|
|
|
30
32
|
currentHeight: number;
|
|
31
33
|
currentGlobalOriginX: number;
|
|
32
34
|
currentGlobalOriginY: number;
|
|
35
|
+
windowWidth: number;
|
|
36
|
+
windowHeight: number;
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
export type EntryExitAnimationFunction = (
|
|
@@ -39,6 +43,7 @@ export type EntryExitAnimationFunction = (
|
|
|
39
43
|
export type AnimationConfigFunction<T> = (targetValues: T) => LayoutAnimation;
|
|
40
44
|
|
|
41
45
|
export interface LayoutAnimationsValues {
|
|
46
|
+
[key: string]: number;
|
|
42
47
|
currentOriginX: number;
|
|
43
48
|
currentOriginY: number;
|
|
44
49
|
currentWidth: number;
|
|
@@ -55,13 +60,20 @@ export interface LayoutAnimationsValues {
|
|
|
55
60
|
windowHeight: number;
|
|
56
61
|
}
|
|
57
62
|
|
|
63
|
+
export enum LayoutAnimationType {
|
|
64
|
+
ENTERING = 1,
|
|
65
|
+
EXITING = 2,
|
|
66
|
+
LAYOUT = 3,
|
|
67
|
+
SHARED_ELEMENT_TRANSITION = 4,
|
|
68
|
+
}
|
|
69
|
+
|
|
58
70
|
export type LayoutAnimationFunction = (
|
|
59
71
|
targetValues: LayoutAnimationsValues
|
|
60
72
|
) => LayoutAnimation;
|
|
61
73
|
|
|
62
74
|
export type LayoutAnimationStartFunction = (
|
|
63
75
|
tag: number,
|
|
64
|
-
type:
|
|
76
|
+
type: LayoutAnimationType,
|
|
65
77
|
yogaValues: LayoutAnimationsValues,
|
|
66
78
|
config: LayoutAnimationFunction
|
|
67
79
|
) => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { BaseAnimationBuilder } from './BaseAnimationBuilder';
|
|
2
2
|
export { ComplexAnimationBuilder } from './ComplexAnimationBuilder';
|
|
3
3
|
export { Keyframe } from './Keyframe';
|
|
4
|
+
export { LayoutAnimationType } from './commonTypes';
|
|
4
5
|
export type {
|
|
5
6
|
LayoutAnimation,
|
|
6
7
|
AnimationFunction,
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import { runOnUI } from '../core';
|
|
2
1
|
import { withStyleAnimation } from '../animation/styleAnimation';
|
|
3
2
|
import { SharedValue } from '../commonTypes';
|
|
4
3
|
import { makeUIMutable } from '../mutables';
|
|
5
4
|
import {
|
|
6
5
|
LayoutAnimationFunction,
|
|
6
|
+
LayoutAnimationType,
|
|
7
7
|
LayoutAnimationsValues,
|
|
8
8
|
} from './animationBuilder';
|
|
9
|
+
import { runOnUIImmediately } from '../threads';
|
|
9
10
|
|
|
10
11
|
const TAG_OFFSET = 1e9;
|
|
11
12
|
|
|
12
13
|
function startObservingProgress(
|
|
13
14
|
tag: number,
|
|
14
|
-
sharedValue: SharedValue<number
|
|
15
|
+
sharedValue: SharedValue<number>,
|
|
16
|
+
animationType: LayoutAnimationType
|
|
15
17
|
): void {
|
|
16
18
|
'worklet';
|
|
19
|
+
const isSharedTransition =
|
|
20
|
+
animationType === LayoutAnimationType.SHARED_ELEMENT_TRANSITION;
|
|
17
21
|
sharedValue.addListener(tag + TAG_OFFSET, () => {
|
|
18
|
-
_notifyAboutProgress(tag, sharedValue.value);
|
|
22
|
+
_notifyAboutProgress(tag, sharedValue.value, isSharedTransition);
|
|
19
23
|
});
|
|
20
24
|
}
|
|
21
25
|
|
|
@@ -38,16 +42,16 @@ function createLayoutAnimationManager() {
|
|
|
38
42
|
return {
|
|
39
43
|
start(
|
|
40
44
|
tag: number,
|
|
41
|
-
type:
|
|
45
|
+
type: LayoutAnimationType,
|
|
42
46
|
yogaValues: LayoutAnimationsValues,
|
|
43
47
|
config: LayoutAnimationFunction
|
|
44
48
|
) {
|
|
45
49
|
const style = config(yogaValues);
|
|
46
50
|
let currentAnimation = style.animations;
|
|
47
51
|
|
|
48
|
-
if (type ===
|
|
52
|
+
if (type === LayoutAnimationType.ENTERING) {
|
|
49
53
|
enteringAnimationForTag.set(tag, currentAnimation);
|
|
50
|
-
} else if (type ===
|
|
54
|
+
} else if (type === LayoutAnimationType.LAYOUT) {
|
|
51
55
|
// When layout animation is requested, but entering is still running, we merge
|
|
52
56
|
// new layout animation targets into the ongoing animation
|
|
53
57
|
const enteringAnimation = enteringAnimationForTag.get(tag);
|
|
@@ -72,20 +76,24 @@ function createLayoutAnimationManager() {
|
|
|
72
76
|
if (finished) {
|
|
73
77
|
enteringAnimationForTag.delete(tag);
|
|
74
78
|
mutableValuesForTag.delete(tag);
|
|
75
|
-
const shouldRemoveView = type ===
|
|
79
|
+
const shouldRemoveView = type === LayoutAnimationType.EXITING;
|
|
76
80
|
stopObservingProgress(tag, value, finished, shouldRemoveView);
|
|
77
81
|
}
|
|
78
82
|
style.callback &&
|
|
79
83
|
style.callback(finished === undefined ? false : finished);
|
|
80
84
|
};
|
|
81
85
|
|
|
82
|
-
startObservingProgress(tag, value);
|
|
86
|
+
startObservingProgress(tag, value, type);
|
|
83
87
|
value.value = animation;
|
|
84
88
|
},
|
|
89
|
+
stop(tag: number) {
|
|
90
|
+
const value = mutableValuesForTag.get(tag);
|
|
91
|
+
stopObservingProgress(tag, value, true, true);
|
|
92
|
+
},
|
|
85
93
|
};
|
|
86
94
|
}
|
|
87
95
|
|
|
88
|
-
|
|
96
|
+
runOnUIImmediately(() => {
|
|
89
97
|
'worklet';
|
|
90
98
|
global.LayoutAnimationsManager = createLayoutAnimationManager();
|
|
91
99
|
})();
|