react-native-reanimated 3.0.2 → 3.1.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/Fabric/FabricUtils.h +1 -1
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +38 -27
- package/Common/cpp/SharedItems/Shareables.h +22 -0
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +2 -0
- package/Common/cpp/Tools/RuntimeDecorator.cpp +4 -1
- package/Common/cpp/Tools/RuntimeDecorator.h +2 -1
- package/Common/cpp/Tools/SingleInstanceChecker.h +14 -2
- package/RNReanimated.podspec +5 -2
- package/android/CMakeLists.txt +4 -0
- package/android/build.gradle +18 -10
- package/android/src/main/cpp/NativeProxy.cpp +316 -337
- package/android/src/main/cpp/NativeProxy.h +53 -11
- package/android/src/main/java/com/swmansion/reanimated/NativeMethodsHelper.java +7 -12
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +11 -8
- package/android/src/main/java/com/swmansion/reanimated/nativeProxy/NativeProxyCommon.java +21 -14
- package/android/src/paper/java/com/swmansion/reanimated/NativeProxy.java +0 -3
- package/ios/Fabric/REAInitializerRCTFabricSurface.mm +1 -0
- package/ios/REANodesManager.h +1 -0
- package/ios/REANodesManager.mm +30 -4
- package/ios/keyboardObserver/REAKeyboardEventObserver.m +51 -130
- package/ios/native/NativeMethods.mm +1 -1
- package/ios/native/NativeProxy.mm +4 -1
- package/ios/native/REAIOSErrorHandler.mm +1 -1
- package/ios/native/REAIOSLogger.mm +1 -1
- package/ios/native/REAIOSScheduler.mm +1 -1
- package/ios/native/REAInitializer.mm +1 -1
- package/ios/native/REAMessageThread.mm +2 -2
- package/lib/commonjs/Animated.js +0 -8
- package/lib/commonjs/Animated.js.map +1 -1
- package/lib/commonjs/ConfigHelper.js +8 -19
- package/lib/commonjs/ConfigHelper.js.map +1 -1
- package/lib/commonjs/createAnimatedComponent.js +20 -158
- package/lib/commonjs/createAnimatedComponent.js.map +1 -1
- package/lib/commonjs/index.js +0 -9
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +0 -7
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/reanimated2/Bezier.js +14 -34
- package/lib/commonjs/reanimated2/Bezier.js.map +1 -1
- package/lib/commonjs/reanimated2/Colors.js +60 -132
- package/lib/commonjs/reanimated2/Colors.js.map +1 -1
- package/lib/commonjs/reanimated2/Easing.js +81 -34
- package/lib/commonjs/reanimated2/Easing.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeMethods.js +8 -20
- package/lib/commonjs/reanimated2/NativeMethods.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js +5 -31
- package/lib/commonjs/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/NativeReanimated/index.js +0 -7
- package/lib/commonjs/reanimated2/NativeReanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/PlatformChecker.js +0 -6
- package/lib/commonjs/reanimated2/PlatformChecker.js.map +1 -1
- package/lib/commonjs/reanimated2/PropAdapters.js +10 -12
- package/lib/commonjs/reanimated2/PropAdapters.js.map +1 -1
- package/lib/commonjs/reanimated2/UpdateProps.js +3 -12
- package/lib/commonjs/reanimated2/UpdateProps.js.map +1 -1
- package/lib/commonjs/reanimated2/ViewDescriptorsSet.js +0 -10
- package/lib/commonjs/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/commonjs/reanimated2/WorkletEventHandler.js +5 -22
- package/lib/commonjs/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/decay.js +7 -18
- package/lib/commonjs/reanimated2/animation/decay.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/delay.js +0 -11
- package/lib/commonjs/reanimated2/animation/delay.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/index.js +0 -8
- package/lib/commonjs/reanimated2/animation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/repeat.js +6 -22
- package/lib/commonjs/reanimated2/animation/repeat.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/sequence.js +3 -20
- package/lib/commonjs/reanimated2/animation/sequence.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/spring.js +11 -23
- package/lib/commonjs/reanimated2/animation/spring.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/styleAnimation.js +3 -35
- package/lib/commonjs/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/timing.js +0 -11
- package/lib/commonjs/reanimated2/animation/timing.js.map +1 -1
- package/lib/commonjs/reanimated2/animation/util.js +11 -41
- package/lib/commonjs/reanimated2/animation/util.js.map +1 -1
- package/lib/commonjs/reanimated2/commonTypes.js +16 -23
- package/lib/commonjs/reanimated2/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/component/FlatList.js +0 -16
- package/lib/commonjs/reanimated2/component/FlatList.js.map +1 -1
- package/lib/commonjs/reanimated2/component/Image.js +0 -4
- package/lib/commonjs/reanimated2/component/Image.js.map +1 -1
- package/lib/commonjs/reanimated2/component/ScrollView.js +0 -4
- package/lib/commonjs/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/commonjs/reanimated2/component/Text.js +0 -4
- package/lib/commonjs/reanimated2/component/Text.js.map +1 -1
- package/lib/commonjs/reanimated2/component/View.js +0 -4
- package/lib/commonjs/reanimated2/component/View.js.map +1 -1
- package/lib/commonjs/reanimated2/core.js +6 -48
- package/lib/commonjs/reanimated2/core.js.map +1 -1
- package/lib/commonjs/reanimated2/errors.js +3 -14
- package/lib/commonjs/reanimated2/errors.js.map +1 -1
- package/lib/commonjs/reanimated2/fabricUtils.js +3 -5
- package/lib/commonjs/reanimated2/fabricUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/fabricUtils.web.js +1 -3
- package/lib/commonjs/reanimated2/fabricUtils.web.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryJS.js +3 -12
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
- package/lib/commonjs/reanimated2/frameCallback/FrameCallbackRegistryUI.js +13 -17
- 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/Hooks.js +0 -5
- package/lib/commonjs/reanimated2/hook/Hooks.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/index.js +0 -12
- package/lib/commonjs/reanimated2/hook/index.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedGestureHandler.js +4 -17
- package/lib/commonjs/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js +2 -9
- package/lib/commonjs/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js +1 -11
- package/lib/commonjs/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js +0 -12
- package/lib/commonjs/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedScrollHandler.js +2 -9
- package/lib/commonjs/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js +8 -23
- package/lib/commonjs/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js +13 -71
- package/lib/commonjs/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js +4 -13
- package/lib/commonjs/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useFrameCallback.js +0 -5
- package/lib/commonjs/reanimated2/hook/useFrameCallback.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js +0 -7
- package/lib/commonjs/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/useSharedValue.js +2 -7
- package/lib/commonjs/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/commonjs/reanimated2/hook/utils.js +8 -39
- package/lib/commonjs/reanimated2/hook/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/index.js +0 -26
- package/lib/commonjs/reanimated2/index.js.map +1 -1
- package/lib/commonjs/reanimated2/initializers.js +21 -43
- package/lib/commonjs/reanimated2/initializers.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolateColor.js +6 -43
- package/lib/commonjs/reanimated2/interpolateColor.js.map +1 -1
- package/lib/commonjs/reanimated2/interpolation.js +14 -29
- package/lib/commonjs/reanimated2/interpolation.js.map +1 -1
- package/lib/commonjs/reanimated2/jestUtils.js +11 -44
- package/lib/commonjs/reanimated2/jestUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js +15 -39
- package/lib/commonjs/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js +9 -28
- package/lib/commonjs/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/MapperRegistry.js +7 -37
- package/lib/commonjs/reanimated2/js-reanimated/MapperRegistry.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/MutableValue.js +5 -18
- package/lib/commonjs/reanimated2/js-reanimated/MutableValue.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/global.js +2 -9
- package/lib/commonjs/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/commonjs/reanimated2/js-reanimated/index.js +3 -14
- package/lib/commonjs/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +7 -26
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +3 -49
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +7 -43
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +4 -5
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js +0 -4
- package/lib/commonjs/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js +4 -23
- package/lib/commonjs/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +3 -74
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Fade.js +3 -53
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Flip.js +3 -63
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +7 -26
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +3 -13
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js +3 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +3 -43
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js +3 -43
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +3 -23
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +3 -83
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/index.js +0 -20
- package/lib/commonjs/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +3 -22
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +5 -29
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +3 -9
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +5 -11
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +3 -8
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +3 -12
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/index.js +0 -12
- package/lib/commonjs/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/index.js +0 -9
- package/lib/commonjs/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js +3 -17
- package/lib/commonjs/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
- package/lib/commonjs/reanimated2/mappers.js +26 -32
- package/lib/commonjs/reanimated2/mappers.js.map +1 -1
- package/lib/commonjs/reanimated2/mock.js +5 -15
- package/lib/commonjs/reanimated2/mock.js.map +1 -1
- package/lib/commonjs/reanimated2/mutables.js +2 -28
- package/lib/commonjs/reanimated2/mutables.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/RNRenderer.js +0 -2
- package/lib/commonjs/reanimated2/platform-specific/RNRenderer.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/checkCppVersion.js +31 -0
- package/lib/commonjs/reanimated2/platform-specific/checkCppVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js +0 -2
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.web.js.map +1 -1
- package/lib/commonjs/reanimated2/platform-specific/jsVersion.js +14 -0
- package/lib/commonjs/reanimated2/platform-specific/jsVersion.js.map +1 -0
- package/lib/commonjs/reanimated2/pluginUtils.js +0 -1
- package/lib/commonjs/reanimated2/pluginUtils.js.map +1 -1
- package/lib/commonjs/reanimated2/shareables.js +92 -49
- package/lib/commonjs/reanimated2/shareables.js.map +1 -1
- package/lib/commonjs/reanimated2/threads.js +42 -46
- package/lib/commonjs/reanimated2/threads.js.map +1 -1
- package/lib/commonjs/reanimated2/utils.js +0 -5
- package/lib/commonjs/reanimated2/utils.js.map +1 -1
- package/lib/commonjs/reanimated2/valueSetter.js +6 -21
- package/lib/commonjs/reanimated2/valueSetter.js.map +1 -1
- package/lib/commonjs/setAndForwardRef.js +3 -3
- package/lib/commonjs/setAndForwardRef.js.map +1 -1
- package/lib/module/Animated.js.map +1 -1
- package/lib/module/ConfigHelper.js +9 -15
- package/lib/module/ConfigHelper.js.map +1 -1
- package/lib/module/createAnimatedComponent.js +20 -139
- package/lib/module/createAnimatedComponent.js.map +1 -1
- package/lib/module/index.js +0 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/reanimated2/Bezier.js +14 -33
- package/lib/module/reanimated2/Bezier.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +59 -109
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/Easing.js +37 -33
- package/lib/module/reanimated2/Easing.js.map +1 -1
- package/lib/module/reanimated2/NativeMethods.js +8 -15
- package/lib/module/reanimated2/NativeMethods.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +5 -27
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/index.js +0 -2
- package/lib/module/reanimated2/NativeReanimated/index.js.map +1 -1
- package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
- package/lib/module/reanimated2/PropAdapters.js +12 -10
- package/lib/module/reanimated2/PropAdapters.js.map +1 -1
- package/lib/module/reanimated2/UpdateProps.js +3 -5
- package/lib/module/reanimated2/UpdateProps.js.map +1 -1
- package/lib/module/reanimated2/ViewDescriptorsSet.js +0 -6
- package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/module/reanimated2/WorkletEventHandler.js +5 -18
- package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/module/reanimated2/animation/decay.js +7 -15
- package/lib/module/reanimated2/animation/decay.js.map +1 -1
- package/lib/module/reanimated2/animation/delay.js +0 -9
- package/lib/module/reanimated2/animation/delay.js.map +1 -1
- package/lib/module/reanimated2/animation/index.js.map +1 -1
- package/lib/module/reanimated2/animation/repeat.js +6 -20
- package/lib/module/reanimated2/animation/repeat.js.map +1 -1
- package/lib/module/reanimated2/animation/sequence.js +3 -18
- package/lib/module/reanimated2/animation/sequence.js.map +1 -1
- package/lib/module/reanimated2/animation/spring.js +11 -21
- package/lib/module/reanimated2/animation/spring.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +7 -31
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/timing.js +0 -8
- package/lib/module/reanimated2/animation/timing.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +10 -33
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +12 -19
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js +0 -4
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/component/Image.js.map +1 -1
- package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/module/reanimated2/component/Text.js.map +1 -1
- package/lib/module/reanimated2/component/View.js.map +1 -1
- package/lib/module/reanimated2/core.js +6 -22
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +3 -13
- package/lib/module/reanimated2/errors.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.js +3 -3
- package/lib/module/reanimated2/fabricUtils.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.web.js +1 -1
- package/lib/module/reanimated2/fabricUtils.web.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js +3 -8
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js +13 -15
- 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/Hooks.js +3 -2
- package/lib/module/reanimated2/hook/Hooks.js.map +1 -1
- package/lib/module/reanimated2/hook/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/hook/index.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js +3 -14
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +2 -5
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +1 -7
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +0 -6
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +2 -7
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +9 -20
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +13 -59
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +4 -8
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +0 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/useSharedValue.js +2 -3
- package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js +8 -21
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +23 -37
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +5 -34
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/interpolation.js +13 -28
- package/lib/module/reanimated2/interpolation.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +11 -35
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +15 -35
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/Mapper.js +9 -23
- package/lib/module/reanimated2/js-reanimated/Mapper.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/MapperRegistry.js +7 -35
- package/lib/module/reanimated2/js-reanimated/MapperRegistry.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/MutableValue.js +5 -16
- package/lib/module/reanimated2/js-reanimated/MutableValue.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/global.js +2 -6
- package/lib/module/reanimated2/js-reanimated/global.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +3 -9
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +7 -23
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +3 -45
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +7 -39
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +3 -3
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js +4 -19
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +3 -52
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +3 -32
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +3 -38
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +7 -16
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +3 -8
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +3 -14
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +3 -26
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +3 -26
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +3 -14
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +3 -50
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +3 -17
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +5 -23
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +3 -5
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +5 -6
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +3 -5
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +3 -8
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js +3 -13
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
- package/lib/module/reanimated2/mappers.js +26 -25
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mock.js +5 -15
- package/lib/module/reanimated2/mock.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +2 -19
- package/lib/module/reanimated2/mutables.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/RNRenderer.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/RNRenderer.web.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js +24 -0
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js.map +1 -0
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js +0 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.web.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js +7 -0
- package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -0
- package/lib/module/reanimated2/pluginUtils.js.map +1 -1
- package/lib/module/reanimated2/shareables.js +96 -44
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +39 -33
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/utils.js +0 -3
- package/lib/module/reanimated2/utils.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +6 -19
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/setAndForwardRef.js +3 -2
- package/lib/module/setAndForwardRef.js.map +1 -1
- package/package.json +46 -40
- package/plugin/.eslintrc.js +7 -0
- package/plugin/README.md +241 -0
- package/plugin/build/plugin.js +714 -0
- package/plugin/build/plugin.js.map +7 -0
- package/plugin/index.js +1 -807
- package/plugin/package.json +23 -0
- package/plugin/src/buildWorkletString.ts +213 -0
- package/plugin/src/commonObjects.ts +60 -0
- package/plugin/src/injectVersion.ts +37 -0
- package/plugin/src/makeWorklet.ts +375 -0
- package/plugin/src/plugin.ts +49 -0
- package/plugin/src/processForCalleesWorklets.ts +106 -0
- package/plugin/src/processIfGestureHandlerEventCallbackFunctionNode.ts +156 -0
- package/plugin/src/processIfWorkletFunction.ts +55 -0
- package/plugin/src/processIfWorkletNode.ts +44 -0
- package/plugin/src/processInlineStylesWarning.ts +129 -0
- package/plugin/src/processWorkletObjectMethod.ts +31 -0
- package/plugin/src/types.ts +15 -0
- package/plugin/src/utils.ts +6 -0
- package/plugin/tsconfig.json +15 -0
- package/plugin/yarn.lock +2193 -0
- package/react-native-reanimated.d.ts +1 -0
- package/scripts/reanimated_utils.rb +2 -2
- package/src/createAnimatedComponent.tsx +2 -3
- package/src/reanimated2/Easing.ts +19 -0
- package/src/reanimated2/NativeMethods.ts +9 -4
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +2 -2
- package/src/reanimated2/UpdateProps.ts +2 -2
- package/src/reanimated2/animation/decay.ts +7 -1
- package/src/reanimated2/animation/styleAnimation.ts +5 -1
- package/src/reanimated2/core.ts +4 -4
- package/src/reanimated2/errors.ts +1 -0
- package/src/reanimated2/frameCallback/FrameCallbackRegistryUI.ts +12 -4
- package/src/reanimated2/globals.d.ts +71 -112
- package/src/reanimated2/hook/commonTypes.ts +1 -1
- package/src/reanimated2/hook/useAnimatedReaction.ts +2 -2
- package/src/reanimated2/hook/useAnimatedSensor.ts +2 -2
- package/src/reanimated2/initializers.ts +11 -8
- package/src/reanimated2/jestUtils.ts +0 -1
- package/src/reanimated2/js-reanimated/JSReanimated.ts +5 -1
- package/src/reanimated2/js-reanimated/index.ts +1 -1
- package/src/reanimated2/mappers.ts +26 -4
- package/src/reanimated2/mock.ts +1 -0
- package/src/reanimated2/platform-specific/checkCppVersion.ts +29 -0
- package/src/reanimated2/platform-specific/jsVersion.ts +6 -0
- package/src/reanimated2/shareables.ts +107 -8
- package/src/reanimated2/threads.ts +36 -17
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js +0 -42
- package/lib/commonjs/reanimated2/platform-specific/checkVersion.js.map +0 -1
- package/lib/module/reanimated2/platform-specific/checkVersion.js +0 -35
- package/lib/module/reanimated2/platform-specific/checkVersion.js.map +0 -1
- package/src/reanimated2/platform-specific/checkVersion.ts +0 -39
|
@@ -4,46 +4,35 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _NativeReanimated = _interopRequireDefault(require("./NativeReanimated"));
|
|
9
|
-
|
|
10
8
|
var _core = require("./core");
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
13
|
function jsListener(eventName, handler) {
|
|
17
14
|
return evt => {
|
|
18
|
-
handler({
|
|
15
|
+
handler({
|
|
16
|
+
...evt.nativeEvent,
|
|
19
17
|
eventName
|
|
20
18
|
});
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
class WorkletEventHandler {
|
|
25
22
|
constructor(worklet) {
|
|
26
23
|
let eventNames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
27
|
-
|
|
28
24
|
_defineProperty(this, "worklet", void 0);
|
|
29
|
-
|
|
30
25
|
_defineProperty(this, "eventNames", void 0);
|
|
31
|
-
|
|
32
26
|
_defineProperty(this, "reattachNeeded", void 0);
|
|
33
|
-
|
|
34
27
|
_defineProperty(this, "listeners", void 0);
|
|
35
|
-
|
|
36
28
|
_defineProperty(this, "viewTag", void 0);
|
|
37
|
-
|
|
38
29
|
_defineProperty(this, "registrations", void 0);
|
|
39
|
-
|
|
40
30
|
this.worklet = worklet;
|
|
41
31
|
this.eventNames = eventNames;
|
|
42
32
|
this.reattachNeeded = false;
|
|
43
33
|
this.listeners = {};
|
|
44
34
|
this.viewTag = undefined;
|
|
45
35
|
this.registrations = [];
|
|
46
|
-
|
|
47
36
|
if (!_NativeReanimated.default.native) {
|
|
48
37
|
this.listeners = eventNames.reduce((acc, eventName) => {
|
|
49
38
|
acc[eventName] = jsListener(eventName, worklet);
|
|
@@ -51,27 +40,21 @@ class WorkletEventHandler {
|
|
|
51
40
|
}, {});
|
|
52
41
|
}
|
|
53
42
|
}
|
|
54
|
-
|
|
55
43
|
updateWorklet(newWorklet) {
|
|
56
44
|
this.worklet = newWorklet;
|
|
57
45
|
this.reattachNeeded = true;
|
|
58
46
|
}
|
|
59
|
-
|
|
60
47
|
registerForEvents(viewTag, fallbackEventName) {
|
|
61
48
|
this.viewTag = viewTag;
|
|
62
49
|
this.registrations = this.eventNames.map(eventName => (0, _core.registerEventHandler)(viewTag + eventName, this.worklet));
|
|
63
|
-
|
|
64
50
|
if (this.registrations.length === 0 && fallbackEventName) {
|
|
65
51
|
this.registrations.push((0, _core.registerEventHandler)(viewTag + fallbackEventName, this.worklet));
|
|
66
52
|
}
|
|
67
53
|
}
|
|
68
|
-
|
|
69
54
|
unregisterFromEvents() {
|
|
70
55
|
this.registrations.forEach(id => (0, _core.unregisterEventHandler)(id));
|
|
71
56
|
this.registrations = [];
|
|
72
57
|
}
|
|
73
|
-
|
|
74
58
|
}
|
|
75
|
-
|
|
76
59
|
exports.default = WorkletEventHandler;
|
|
77
60
|
//# sourceMappingURL=WorkletEventHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["jsListener","eventName","handler","evt","nativeEvent","WorkletEventHandler","constructor","worklet","eventNames","reattachNeeded","listeners","viewTag","
|
|
1
|
+
{"version":3,"names":["_NativeReanimated","_interopRequireDefault","require","_core","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","jsListener","eventName","handler","evt","nativeEvent","WorkletEventHandler","constructor","worklet","eventNames","arguments","length","reattachNeeded","listeners","viewTag","registrations","NativeReanimatedModule","native","reduce","acc","updateWorklet","newWorklet","registerForEvents","fallbackEventName","map","registerEventHandler","push","unregisterFromEvents","forEach","id","unregisterEventHandler","exports"],"sources":["WorkletEventHandler.ts"],"sourcesContent":["import { NativeEvent } from './commonTypes';\nimport NativeReanimatedModule from './NativeReanimated';\nimport { registerEventHandler, unregisterEventHandler } from './core';\n\nfunction jsListener<T extends NativeEvent<T>>(\n eventName: string,\n handler: (event: T) => void\n) {\n return (evt: T) => {\n handler({ ...evt.nativeEvent, eventName });\n };\n}\n\nexport default class WorkletEventHandler<T extends NativeEvent<T>> {\n worklet: (event: T) => void;\n eventNames: string[];\n reattachNeeded: boolean;\n listeners: Record<string, (event: T) => void>;\n viewTag: number | undefined;\n registrations: string[];\n constructor(worklet: (event: T) => void, eventNames: string[] = []) {\n this.worklet = worklet;\n this.eventNames = eventNames;\n this.reattachNeeded = false;\n this.listeners = {};\n this.viewTag = undefined;\n this.registrations = [];\n\n if (!NativeReanimatedModule.native) {\n this.listeners = eventNames.reduce(\n (acc: Record<string, (event: T) => void>, eventName: string) => {\n acc[eventName] = jsListener(eventName, worklet);\n return acc;\n },\n {}\n );\n }\n }\n\n updateWorklet(newWorklet: (event: T) => void): void {\n this.worklet = newWorklet;\n this.reattachNeeded = true;\n }\n\n registerForEvents(viewTag: number, fallbackEventName?: string): void {\n this.viewTag = viewTag;\n this.registrations = this.eventNames.map((eventName) =>\n registerEventHandler(viewTag + eventName, this.worklet)\n );\n if (this.registrations.length === 0 && fallbackEventName) {\n this.registrations.push(\n registerEventHandler(viewTag + fallbackEventName, this.worklet)\n );\n }\n }\n\n unregisterFromEvents(): void {\n this.registrations.forEach((id) => unregisterEventHandler(id));\n this.registrations = [];\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAAsE,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,gBAAAH,GAAA,EAAAI,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAJ,GAAA,IAAAO,MAAA,CAAAC,cAAA,CAAAR,GAAA,EAAAI,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,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CAACJ,SAAS,GAAGJ,UAAU,CAACS,MAAM,CAChC,CAACC,GAAuC,EAAEjB,SAAiB,KAAK;QAC9DiB,GAAG,CAACjB,SAAS,CAAC,GAAGD,UAAU,CAACC,SAAS,EAAEM,OAAO,CAAC;QAC/C,OAAOW,GAAG;MACZ,CAAC,EACD,CAAC,CAAC,CACH;IACH;EACF;EAEAC,aAAaA,CAACC,UAA8B,EAAQ;IAClD,IAAI,CAACb,OAAO,GAAGa,UAAU;IACzB,IAAI,CAACT,cAAc,GAAG,IAAI;EAC5B;EAEAU,iBAAiBA,CAACR,OAAe,EAAES,iBAA0B,EAAQ;IACnE,IAAI,CAACT,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACC,aAAa,GAAG,IAAI,CAACN,UAAU,CAACe,GAAG,CAAEtB,SAAS,IACjD,IAAAuB,0BAAoB,EAACX,OAAO,GAAGZ,SAAS,EAAE,IAAI,CAACM,OAAO,CAAC,CACxD;IACD,IAAI,IAAI,CAACO,aAAa,CAACJ,MAAM,KAAK,CAAC,IAAIY,iBAAiB,EAAE;MACxD,IAAI,CAACR,aAAa,CAACW,IAAI,CACrB,IAAAD,0BAAoB,EAACX,OAAO,GAAGS,iBAAiB,EAAE,IAAI,CAACf,OAAO,CAAC,CAChE;IACH;EACF;EAEAmB,oBAAoBA,CAAA,EAAS;IAC3B,IAAI,CAACZ,aAAa,CAACa,OAAO,CAAEC,EAAE,IAAK,IAAAC,4BAAsB,EAACD,EAAE,CAAC,CAAC;IAC9D,IAAI,CAACd,aAAa,GAAG,EAAE;EACzB;AACF;AAACgB,OAAA,CAAArD,OAAA,GAAA4B,mBAAA"}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.withDecay = withDecay;
|
|
7
|
-
|
|
8
7
|
var _util = require("./util");
|
|
9
|
-
|
|
10
8
|
var _reactNative = require("react-native");
|
|
11
|
-
|
|
12
9
|
function withDecay(userConfig, callback) {
|
|
13
10
|
'worklet';
|
|
14
11
|
|
|
@@ -17,19 +14,22 @@ function withDecay(userConfig, callback) {
|
|
|
17
14
|
|
|
18
15
|
const config = {
|
|
19
16
|
deceleration: 0.998,
|
|
20
|
-
velocityFactor:
|
|
17
|
+
velocityFactor: 1,
|
|
21
18
|
velocity: 0,
|
|
22
19
|
rubberBandFactor: 0.6
|
|
23
20
|
};
|
|
24
|
-
|
|
25
21
|
if (userConfig) {
|
|
26
22
|
Object.keys(userConfig).forEach(key => config[key] = userConfig[key]);
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
const VELOCITY_EPS = _reactNative.Platform.OS !== 'web' ? 1 : 1 / 20;
|
|
30
25
|
const SLOPE_FACTOR = 0.1;
|
|
31
|
-
let decay;
|
|
32
26
|
|
|
27
|
+
// @piaskowyk: Velocity is expressed in pixels per second
|
|
28
|
+
// but pixels on Web are handled differently than on native
|
|
29
|
+
if (_reactNative.Platform.OS === 'web') {
|
|
30
|
+
config.velocity *= 1000;
|
|
31
|
+
}
|
|
32
|
+
let decay;
|
|
33
33
|
if (config.rubberBandEffect) {
|
|
34
34
|
decay = (animation, now) => {
|
|
35
35
|
const {
|
|
@@ -42,18 +42,15 @@ function withDecay(userConfig, callback) {
|
|
|
42
42
|
const deltaTime = Math.min(now - lastTimestamp, 64);
|
|
43
43
|
const clampIndex = initialVelocity > 0 ? 1 : 0;
|
|
44
44
|
let derivative = 0;
|
|
45
|
-
|
|
46
45
|
if (current < config.clamp[0] || current > config.clamp[1]) {
|
|
47
46
|
derivative = current - config.clamp[clampIndex];
|
|
48
47
|
}
|
|
49
|
-
|
|
50
48
|
if (derivative !== 0) {
|
|
51
49
|
animation.springActive = true;
|
|
52
50
|
} else if (derivative === 0 && animation.springActive) {
|
|
53
51
|
animation.current = config.clamp[clampIndex];
|
|
54
52
|
return true;
|
|
55
53
|
}
|
|
56
|
-
|
|
57
54
|
const v = velocity * Math.exp(-(1 - config.deceleration) * (now - startTimestamp) * SLOPE_FACTOR) - derivative * config.rubberBandFactor;
|
|
58
55
|
animation.current = current + v * config.velocityFactor * deltaTime / 1000;
|
|
59
56
|
animation.velocity = v;
|
|
@@ -74,7 +71,6 @@ function withDecay(userConfig, callback) {
|
|
|
74
71
|
animation.current = current + v * config.velocityFactor * deltaTime / 1000;
|
|
75
72
|
animation.velocity = v;
|
|
76
73
|
animation.lastTimestamp = now;
|
|
77
|
-
|
|
78
74
|
if (config.clamp) {
|
|
79
75
|
if (initialVelocity < 0 && animation.current <= config.clamp[0]) {
|
|
80
76
|
animation.current = config.clamp[0];
|
|
@@ -84,31 +80,25 @@ function withDecay(userConfig, callback) {
|
|
|
84
80
|
return true;
|
|
85
81
|
}
|
|
86
82
|
}
|
|
87
|
-
|
|
88
83
|
return Math.abs(v) < VELOCITY_EPS;
|
|
89
84
|
};
|
|
90
85
|
}
|
|
91
|
-
|
|
92
86
|
function validateConfig() {
|
|
93
87
|
if (config.clamp) {
|
|
94
88
|
if (!Array.isArray(config.clamp)) {
|
|
95
89
|
throw Error(`config.clamp must be an array but is ${typeof config.clamp}`);
|
|
96
90
|
}
|
|
97
|
-
|
|
98
91
|
if (config.clamp.length !== 2) {
|
|
99
92
|
throw Error(`clamp array must contain 2 items but is given ${config.clamp.length}`);
|
|
100
93
|
}
|
|
101
94
|
}
|
|
102
|
-
|
|
103
95
|
if (config.velocityFactor <= 0) {
|
|
104
96
|
throw Error(`config.velocityFactor must be greather then 0 but is ${config.velocityFactor}`);
|
|
105
97
|
}
|
|
106
|
-
|
|
107
98
|
if (config.rubberBandEffect && !config.clamp) {
|
|
108
99
|
throw Error('You need to set `clamp` property when using `rubberBandEffect`.');
|
|
109
100
|
}
|
|
110
101
|
}
|
|
111
|
-
|
|
112
102
|
function onStart(animation, value, now) {
|
|
113
103
|
animation.current = value;
|
|
114
104
|
animation.lastTimestamp = now;
|
|
@@ -116,7 +106,6 @@ function withDecay(userConfig, callback) {
|
|
|
116
106
|
animation.initialVelocity = config.velocity;
|
|
117
107
|
validateConfig();
|
|
118
108
|
}
|
|
119
|
-
|
|
120
109
|
return {
|
|
121
110
|
onFrame: decay,
|
|
122
111
|
onStart,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withDecay","userConfig","callback","defineAnimation","config","deceleration","velocityFactor","
|
|
1
|
+
{"version":3,"names":["_util","require","_reactNative","withDecay","userConfig","callback","defineAnimation","config","deceleration","velocityFactor","velocity","rubberBandFactor","Object","keys","forEach","key","VELOCITY_EPS","Platform","OS","SLOPE_FACTOR","decay","rubberBandEffect","animation","now","lastTimestamp","startTimestamp","current","initialVelocity","deltaTime","Math","min","clampIndex","derivative","clamp","springActive","v","exp","abs","validateConfig","Array","isArray","Error","length","onStart","value","onFrame"],"sources":["decay.ts"],"sourcesContent":["import { defineAnimation } from './util';\nimport {\n Animation,\n AnimationCallback,\n AnimationObject,\n AnimatableValue,\n Timestamp,\n} from '../commonTypes';\nimport { Platform } from 'react-native';\n\ninterface DecayConfig {\n deceleration?: number;\n velocityFactor?: number;\n clamp?: number[];\n velocity?: number;\n}\n\ninterface DefaultDecayConfig {\n deceleration: number;\n velocityFactor: number;\n clamp?: number[];\n velocity: number;\n rubberBandEffect?: boolean;\n rubberBandFactor: number;\n}\n\nexport interface DecayAnimation extends Animation<DecayAnimation> {\n lastTimestamp: Timestamp;\n startTimestamp: Timestamp;\n initialVelocity: number;\n velocity: number;\n current: AnimatableValue;\n}\n\nexport interface InnerDecayAnimation\n extends Omit<DecayAnimation, 'current'>,\n AnimationObject {\n current: number;\n}\n\nexport function withDecay(\n userConfig: DecayConfig,\n callback?: AnimationCallback\n): Animation<DecayAnimation> {\n 'worklet';\n\n return defineAnimation<DecayAnimation>(0, () => {\n 'worklet';\n const config: DefaultDecayConfig = {\n deceleration: 0.998,\n velocityFactor: 1,\n velocity: 0,\n rubberBandFactor: 0.6,\n };\n if (userConfig) {\n Object.keys(userConfig).forEach(\n (key) =>\n ((config as any)[key] = userConfig[key as keyof typeof userConfig])\n );\n }\n\n const VELOCITY_EPS = Platform.OS !== 'web' ? 1 : 1 / 20;\n const SLOPE_FACTOR = 0.1;\n\n // @piaskowyk: Velocity is expressed in pixels per second\n // but pixels on Web are handled differently than on native\n if (Platform.OS === 'web') {\n config.velocity *= 1000;\n }\n\n let decay: (animation: InnerDecayAnimation, now: number) => boolean;\n\n if (config.rubberBandEffect) {\n decay = (animation: InnerDecayAnimation, now: number): boolean => {\n const {\n lastTimestamp,\n startTimestamp,\n current,\n initialVelocity,\n velocity,\n } = animation;\n\n const deltaTime = Math.min(now - lastTimestamp, 64);\n const clampIndex = initialVelocity > 0 ? 1 : 0;\n let derivative = 0;\n if (current < config.clamp![0] || current > config.clamp![1]) {\n derivative = current - config.clamp![clampIndex];\n }\n\n if (derivative !== 0) {\n animation.springActive = true;\n } else if (derivative === 0 && animation.springActive) {\n animation.current = config.clamp![clampIndex];\n return true;\n }\n\n const v =\n velocity *\n Math.exp(\n -(1 - config.deceleration) * (now - startTimestamp) * SLOPE_FACTOR\n ) -\n derivative * config.rubberBandFactor;\n\n animation.current =\n current + (v * config.velocityFactor * deltaTime) / 1000;\n animation.velocity = v;\n animation.lastTimestamp = now;\n return false;\n };\n } else {\n decay = (animation: InnerDecayAnimation, now: number): boolean => {\n const {\n lastTimestamp,\n startTimestamp,\n initialVelocity,\n current,\n velocity,\n } = animation;\n\n const deltaTime = Math.min(now - lastTimestamp, 64);\n const v =\n velocity *\n Math.exp(\n -(1 - config.deceleration) * (now - startTimestamp) * SLOPE_FACTOR\n );\n animation.current =\n current + (v * config.velocityFactor * deltaTime) / 1000;\n animation.velocity = v;\n animation.lastTimestamp = now;\n\n if (config.clamp) {\n if (initialVelocity < 0 && animation.current <= config.clamp[0]) {\n animation.current = config.clamp[0];\n return true;\n } else if (\n initialVelocity > 0 &&\n animation.current >= config.clamp[1]\n ) {\n animation.current = config.clamp[1];\n return true;\n }\n }\n\n return Math.abs(v) < VELOCITY_EPS;\n };\n }\n\n function validateConfig(): void {\n if (config.clamp) {\n if (!Array.isArray(config.clamp)) {\n throw Error(\n `config.clamp must be an array but is ${typeof config.clamp}`\n );\n }\n if (config.clamp.length !== 2) {\n throw Error(\n `clamp array must contain 2 items but is given ${config.clamp.length}`\n );\n }\n }\n if (config.velocityFactor <= 0) {\n throw Error(\n `config.velocityFactor must be greather then 0 but is ${config.velocityFactor}`\n );\n }\n if (config.rubberBandEffect && !config.clamp) {\n throw Error(\n 'You need to set `clamp` property when using `rubberBandEffect`.'\n );\n }\n }\n\n function onStart(\n animation: DecayAnimation,\n value: number,\n now: Timestamp\n ): void {\n animation.current = value;\n animation.lastTimestamp = now;\n animation.startTimestamp = now;\n animation.initialVelocity = config.velocity;\n validateConfig();\n }\n\n return {\n onFrame: decay,\n onStart,\n callback,\n velocity: config.velocity ?? 0,\n initialVelocity: 0,\n current: 0,\n lastTimestamp: 0,\n startTimestamp: 0,\n } as DecayAnimation;\n });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAQA,IAAAC,YAAA,GAAAD,OAAA;AAgCO,SAASE,SAASA,CACvBC,UAAuB,EACvBC,QAA4B,EACD;EAC3B,SAAS;;EAET,OAAO,IAAAC,qBAAe,EAAiB,CAAC,EAAE,MAAM;IAC9C,SAAS;;IACT,MAAMC,MAA0B,GAAG;MACjCC,YAAY,EAAE,KAAK;MACnBC,cAAc,EAAE,CAAC;MACjBC,QAAQ,EAAE,CAAC;MACXC,gBAAgB,EAAE;IACpB,CAAC;IACD,IAAIP,UAAU,EAAE;MACdQ,MAAM,CAACC,IAAI,CAACT,UAAU,CAAC,CAACU,OAAO,CAC5BC,GAAG,IACAR,MAAM,CAASQ,GAAG,CAAC,GAAGX,UAAU,CAACW,GAAG,CAA6B,CACtE;IACH;IAEA,MAAMC,YAAY,GAAGC,qBAAQ,CAACC,EAAE,KAAK,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE;IACvD,MAAMC,YAAY,GAAG,GAAG;;IAExB;IACA;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|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.withDelay = withDelay;
|
|
7
|
-
|
|
8
7
|
var _util = require("./util");
|
|
9
|
-
|
|
10
8
|
function withDelay(delayMs, _nextAnimation) {
|
|
11
9
|
'worklet';
|
|
12
10
|
|
|
@@ -14,54 +12,45 @@ function withDelay(delayMs, _nextAnimation) {
|
|
|
14
12
|
'worklet';
|
|
15
13
|
|
|
16
14
|
const nextAnimation = typeof _nextAnimation === 'function' ? _nextAnimation() : _nextAnimation;
|
|
17
|
-
|
|
18
15
|
function delay(animation, now) {
|
|
19
16
|
const {
|
|
20
17
|
startTime,
|
|
21
18
|
started,
|
|
22
19
|
previousAnimation
|
|
23
20
|
} = animation;
|
|
24
|
-
|
|
25
21
|
if (now - startTime > delayMs) {
|
|
26
22
|
if (!started) {
|
|
27
23
|
nextAnimation.onStart(nextAnimation, animation.current, now, previousAnimation);
|
|
28
24
|
animation.previousAnimation = null;
|
|
29
25
|
animation.started = true;
|
|
30
26
|
}
|
|
31
|
-
|
|
32
27
|
const finished = nextAnimation.onFrame(nextAnimation, now);
|
|
33
28
|
animation.current = nextAnimation.current;
|
|
34
29
|
return finished;
|
|
35
30
|
} else if (previousAnimation) {
|
|
36
31
|
const finished = previousAnimation.finished || previousAnimation.onFrame(previousAnimation, now);
|
|
37
32
|
animation.current = previousAnimation.current;
|
|
38
|
-
|
|
39
33
|
if (finished) {
|
|
40
34
|
animation.previousAnimation = null;
|
|
41
35
|
}
|
|
42
36
|
}
|
|
43
|
-
|
|
44
37
|
return false;
|
|
45
38
|
}
|
|
46
|
-
|
|
47
39
|
function onStart(animation, value, now, previousAnimation) {
|
|
48
40
|
animation.startTime = now;
|
|
49
41
|
animation.started = false;
|
|
50
42
|
animation.current = value;
|
|
51
|
-
|
|
52
43
|
if (previousAnimation === animation) {
|
|
53
44
|
animation.previousAnimation = previousAnimation.previousAnimation;
|
|
54
45
|
} else {
|
|
55
46
|
animation.previousAnimation = previousAnimation;
|
|
56
47
|
}
|
|
57
48
|
}
|
|
58
|
-
|
|
59
49
|
const callback = finished => {
|
|
60
50
|
if (nextAnimation.callback) {
|
|
61
51
|
nextAnimation.callback(finished);
|
|
62
52
|
}
|
|
63
53
|
};
|
|
64
|
-
|
|
65
54
|
return {
|
|
66
55
|
isHigherOrder: true,
|
|
67
56
|
onFrame: delay,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withDelay","delayMs","_nextAnimation","defineAnimation","nextAnimation","delay","animation","now","startTime","started","previousAnimation","onStart","current","finished","onFrame","value","callback","isHigherOrder"],"sources":["delay.ts"],"sourcesContent":["import { defineAnimation } from './util';\nimport { Animation, Timestamp, AnimatableValue } from '../commonTypes';\nimport { NextAnimation, DelayAnimation } from './commonTypes';\n\nexport function withDelay(\n delayMs: number,\n _nextAnimation: NextAnimation<DelayAnimation>\n): Animation<DelayAnimation> {\n 'worklet';\n return defineAnimation<DelayAnimation>(_nextAnimation, () => {\n 'worklet';\n const nextAnimation =\n typeof _nextAnimation === 'function' ? _nextAnimation() : _nextAnimation;\n\n function delay(animation: DelayAnimation, now: Timestamp): boolean {\n const { startTime, started, previousAnimation } = animation;\n\n if (now - startTime > delayMs) {\n if (!started) {\n nextAnimation.onStart(\n nextAnimation,\n animation.current,\n now,\n previousAnimation as DelayAnimation\n );\n animation.previousAnimation = null;\n animation.started = true;\n }\n const finished = nextAnimation.onFrame(nextAnimation, now);\n animation.current = nextAnimation.current;\n return finished;\n } else if (previousAnimation) {\n const finished =\n previousAnimation.finished ||\n previousAnimation.onFrame(previousAnimation, now);\n animation.current = previousAnimation.current;\n if (finished) {\n animation.previousAnimation = null;\n }\n }\n return false;\n }\n\n function onStart(\n animation: DelayAnimation,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: DelayAnimation\n ): void {\n animation.startTime = now;\n animation.started = false;\n animation.current = value;\n if (previousAnimation === animation) {\n animation.previousAnimation = previousAnimation.previousAnimation;\n } else {\n animation.previousAnimation = previousAnimation;\n }\n }\n\n const callback = (finished?: boolean): void => {\n if (nextAnimation.callback) {\n nextAnimation.callback(finished);\n }\n };\n\n return {\n isHigherOrder: true,\n onFrame: delay,\n onStart,\n current: nextAnimation.current,\n callback,\n previousAnimation: null,\n startTime: 0,\n started: false,\n };\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_util","require","withDelay","delayMs","_nextAnimation","defineAnimation","nextAnimation","delay","animation","now","startTime","started","previousAnimation","onStart","current","finished","onFrame","value","callback","isHigherOrder"],"sources":["delay.ts"],"sourcesContent":["import { defineAnimation } from './util';\nimport { Animation, Timestamp, AnimatableValue } from '../commonTypes';\nimport { NextAnimation, DelayAnimation } from './commonTypes';\n\nexport function withDelay(\n delayMs: number,\n _nextAnimation: NextAnimation<DelayAnimation>\n): Animation<DelayAnimation> {\n 'worklet';\n return defineAnimation<DelayAnimation>(_nextAnimation, () => {\n 'worklet';\n const nextAnimation =\n typeof _nextAnimation === 'function' ? _nextAnimation() : _nextAnimation;\n\n function delay(animation: DelayAnimation, now: Timestamp): boolean {\n const { startTime, started, previousAnimation } = animation;\n\n if (now - startTime > delayMs) {\n if (!started) {\n nextAnimation.onStart(\n nextAnimation,\n animation.current,\n now,\n previousAnimation as DelayAnimation\n );\n animation.previousAnimation = null;\n animation.started = true;\n }\n const finished = nextAnimation.onFrame(nextAnimation, now);\n animation.current = nextAnimation.current;\n return finished;\n } else if (previousAnimation) {\n const finished =\n previousAnimation.finished ||\n previousAnimation.onFrame(previousAnimation, now);\n animation.current = previousAnimation.current;\n if (finished) {\n animation.previousAnimation = null;\n }\n }\n return false;\n }\n\n function onStart(\n animation: DelayAnimation,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: DelayAnimation\n ): void {\n animation.startTime = now;\n animation.started = false;\n animation.current = value;\n if (previousAnimation === animation) {\n animation.previousAnimation = previousAnimation.previousAnimation;\n } else {\n animation.previousAnimation = previousAnimation;\n }\n }\n\n const callback = (finished?: boolean): void => {\n if (nextAnimation.callback) {\n nextAnimation.callback(finished);\n }\n };\n\n return {\n isHigherOrder: true,\n onFrame: delay,\n onStart,\n current: nextAnimation.current,\n callback,\n previousAnimation: null,\n startTime: 0,\n started: false,\n };\n });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAIO,SAASC,SAASA,CACvBC,OAAe,EACfC,cAA6C,EAClB;EAC3B,SAAS;;EACT,OAAO,IAAAC,qBAAe,EAAiBD,cAAc,EAAE,MAAM;IAC3D,SAAS;;IACT,MAAME,aAAa,GACjB,OAAOF,cAAc,KAAK,UAAU,GAAGA,cAAc,EAAE,GAAGA,cAAc;IAE1E,SAASG,KAAKA,CAACC,SAAyB,EAAEC,GAAc,EAAW;MACjE,MAAM;QAAEC,SAAS;QAAEC,OAAO;QAAEC;MAAkB,CAAC,GAAGJ,SAAS;MAE3D,IAAIC,GAAG,GAAGC,SAAS,GAAGP,OAAO,EAAE;QAC7B,IAAI,CAACQ,OAAO,EAAE;UACZL,aAAa,CAACO,OAAO,CACnBP,aAAa,EACbE,SAAS,CAACM,OAAO,EACjBL,GAAG,EACHG,iBAAiB,CAClB;UACDJ,SAAS,CAACI,iBAAiB,GAAG,IAAI;UAClCJ,SAAS,CAACG,OAAO,GAAG,IAAI;QAC1B;QACA,MAAMI,QAAQ,GAAGT,aAAa,CAACU,OAAO,CAACV,aAAa,EAAEG,GAAG,CAAC;QAC1DD,SAAS,CAACM,OAAO,GAAGR,aAAa,CAACQ,OAAO;QACzC,OAAOC,QAAQ;MACjB,CAAC,MAAM,IAAIH,iBAAiB,EAAE;QAC5B,MAAMG,QAAQ,GACZH,iBAAiB,CAACG,QAAQ,IAC1BH,iBAAiB,CAACI,OAAO,CAACJ,iBAAiB,EAAEH,GAAG,CAAC;QACnDD,SAAS,CAACM,OAAO,GAAGF,iBAAiB,CAACE,OAAO;QAC7C,IAAIC,QAAQ,EAAE;UACZP,SAAS,CAACI,iBAAiB,GAAG,IAAI;QACpC;MACF;MACA,OAAO,KAAK;IACd;IAEA,SAASC,OAAOA,CACdL,SAAyB,EACzBS,KAAsB,EACtBR,GAAc,EACdG,iBAAiC,EAC3B;MACNJ,SAAS,CAACE,SAAS,GAAGD,GAAG;MACzBD,SAAS,CAACG,OAAO,GAAG,KAAK;MACzBH,SAAS,CAACM,OAAO,GAAGG,KAAK;MACzB,IAAIL,iBAAiB,KAAKJ,SAAS,EAAE;QACnCA,SAAS,CAACI,iBAAiB,GAAGA,iBAAiB,CAACA,iBAAiB;MACnE,CAAC,MAAM;QACLJ,SAAS,CAACI,iBAAiB,GAAGA,iBAAiB;MACjD;IACF;IAEA,MAAMM,QAAQ,GAAIH,QAAkB,IAAW;MAC7C,IAAIT,aAAa,CAACY,QAAQ,EAAE;QAC1BZ,aAAa,CAACY,QAAQ,CAACH,QAAQ,CAAC;MAClC;IACF,CAAC;IAED,OAAO;MACLI,aAAa,EAAE,IAAI;MACnBH,OAAO,EAAET,KAAK;MACdM,OAAO;MACPC,OAAO,EAAER,aAAa,CAACQ,OAAO;MAC9BI,QAAQ;MACRN,iBAAiB,EAAE,IAAI;MACvBF,SAAS,EAAE,CAAC;MACZC,OAAO,EAAE;IACX,CAAC;EACH,CAAC,CAAC;AACJ"}
|
|
@@ -63,20 +63,12 @@ Object.defineProperty(exports, "withTiming", {
|
|
|
63
63
|
return _timing.withTiming;
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
|
-
|
|
67
66
|
var _util = require("./util");
|
|
68
|
-
|
|
69
67
|
var _timing = require("./timing");
|
|
70
|
-
|
|
71
68
|
var _spring = require("./spring");
|
|
72
|
-
|
|
73
69
|
var _decay = require("./decay");
|
|
74
|
-
|
|
75
70
|
var _delay = require("./delay");
|
|
76
|
-
|
|
77
71
|
var _repeat = require("./repeat");
|
|
78
|
-
|
|
79
72
|
var _sequence = require("./sequence");
|
|
80
|
-
|
|
81
73
|
var _styleAnimation = require("./styleAnimation");
|
|
82
74
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export type {\n HigherOrderAnimation,\n NextAnimation,\n DelayAnimation,\n RepeatAnimation,\n SequenceAnimation,\n StyleLayoutAnimation,\n} from './commonTypes';\nexport { cancelAnimation, defineAnimation, initialUpdaterRun } from './util';\nexport { withTiming } from './timing';\nexport type { TimingAnimation } from './timing';\nexport { withSpring } from './spring';\nexport type { SpringAnimation } from './spring';\nexport { withDecay } from './decay';\nexport type { DecayAnimation } from './decay';\nexport { withDelay } from './delay';\nexport { withRepeat } from './repeat';\nexport { withSequence } from './sequence';\nexport { withStyleAnimation } from './styleAnimation';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_util","require","_timing","_spring","_decay","_delay","_repeat","_sequence","_styleAnimation"],"sources":["index.ts"],"sourcesContent":["export type {\n HigherOrderAnimation,\n NextAnimation,\n DelayAnimation,\n RepeatAnimation,\n SequenceAnimation,\n StyleLayoutAnimation,\n} from './commonTypes';\nexport { cancelAnimation, defineAnimation, initialUpdaterRun } from './util';\nexport { withTiming } from './timing';\nexport type { TimingAnimation } from './timing';\nexport { withSpring } from './spring';\nexport type { SpringAnimation } from './spring';\nexport { withDecay } from './decay';\nexport type { DecayAnimation } from './decay';\nexport { withDelay } from './delay';\nexport { withRepeat } from './repeat';\nexport { withSequence } from './sequence';\nexport { withStyleAnimation } from './styleAnimation';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,eAAA,GAAAP,OAAA"}
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.withRepeat = withRepeat;
|
|
7
|
-
|
|
8
7
|
var _util = require("./util");
|
|
9
|
-
|
|
10
8
|
function withRepeat(_nextAnimation) {
|
|
11
9
|
'worklet';
|
|
12
10
|
|
|
@@ -17,49 +15,36 @@ function withRepeat(_nextAnimation) {
|
|
|
17
15
|
'worklet';
|
|
18
16
|
|
|
19
17
|
const nextAnimation = typeof _nextAnimation === 'function' ? _nextAnimation() : _nextAnimation;
|
|
20
|
-
|
|
21
18
|
function repeat(animation, now) {
|
|
22
19
|
const finished = nextAnimation.onFrame(nextAnimation, now);
|
|
23
20
|
animation.current = nextAnimation.current;
|
|
24
|
-
|
|
25
21
|
if (finished) {
|
|
26
|
-
animation.reps += 1;
|
|
22
|
+
animation.reps += 1;
|
|
23
|
+
// call inner animation's callback on every repetition
|
|
27
24
|
// as the second argument the animation's current value is passed
|
|
28
|
-
|
|
29
25
|
if (nextAnimation.callback) {
|
|
30
|
-
nextAnimation.callback(true
|
|
31
|
-
/* finished */
|
|
32
|
-
, animation.current);
|
|
26
|
+
nextAnimation.callback(true /* finished */, animation.current);
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
if (numberOfReps > 0 && animation.reps >= numberOfReps) {
|
|
36
29
|
return true;
|
|
37
30
|
}
|
|
38
|
-
|
|
39
31
|
const startValue = reverse ? nextAnimation.current : animation.startValue;
|
|
40
|
-
|
|
41
32
|
if (reverse) {
|
|
42
33
|
nextAnimation.toValue = animation.startValue;
|
|
43
34
|
animation.startValue = startValue;
|
|
44
35
|
}
|
|
45
|
-
|
|
46
36
|
nextAnimation.onStart(nextAnimation, startValue, now, nextAnimation.previousAnimation);
|
|
47
37
|
return false;
|
|
48
38
|
}
|
|
49
|
-
|
|
50
39
|
return false;
|
|
51
40
|
}
|
|
52
|
-
|
|
53
41
|
const repCallback = finished => {
|
|
54
42
|
if (callback) {
|
|
55
43
|
callback(finished);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
}
|
|
45
|
+
// when cancelled call inner animation's callback
|
|
59
46
|
if (!finished && nextAnimation.callback) {
|
|
60
|
-
nextAnimation.callback(false
|
|
61
|
-
/* finished */
|
|
62
|
-
);
|
|
47
|
+
nextAnimation.callback(false /* finished */);
|
|
63
48
|
}
|
|
64
49
|
};
|
|
65
50
|
|
|
@@ -68,7 +53,6 @@ function withRepeat(_nextAnimation) {
|
|
|
68
53
|
animation.reps = 0;
|
|
69
54
|
nextAnimation.onStart(nextAnimation, value, now, previousAnimation);
|
|
70
55
|
}
|
|
71
|
-
|
|
72
56
|
return {
|
|
73
57
|
isHigherOrder: true,
|
|
74
58
|
onFrame: repeat,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withRepeat","_nextAnimation","numberOfReps","reverse","callback","defineAnimation","nextAnimation","repeat","animation","now","finished","onFrame","current","reps","startValue","toValue","onStart","previousAnimation","repCallback","value","isHigherOrder"],"sources":["repeat.ts"],"sourcesContent":["import { defineAnimation } from './util';\nimport {\n Animation,\n AnimationCallback,\n AnimatableValue,\n Timestamp,\n} from '../commonTypes';\nimport { NextAnimation, RepeatAnimation } from './commonTypes';\n\nexport interface InnerRepeatAnimation\n extends Omit<RepeatAnimation, 'toValue' | 'startValue'> {\n toValue: number;\n startValue: number;\n}\n\nexport function withRepeat(\n _nextAnimation: NextAnimation<RepeatAnimation>,\n numberOfReps = 2,\n reverse = false,\n callback?: AnimationCallback\n): Animation<RepeatAnimation> {\n 'worklet';\n\n return defineAnimation<RepeatAnimation>(_nextAnimation, () => {\n 'worklet';\n\n const nextAnimation: RepeatAnimation =\n typeof _nextAnimation === 'function' ? _nextAnimation() : _nextAnimation;\n\n function repeat(animation: InnerRepeatAnimation, now: Timestamp): boolean {\n const finished = nextAnimation.onFrame(nextAnimation, now);\n animation.current = nextAnimation.current;\n if (finished) {\n animation.reps += 1;\n // call inner animation's callback on every repetition\n // as the second argument the animation's current value is passed\n if (nextAnimation.callback) {\n nextAnimation.callback(true /* finished */, animation.current);\n }\n if (numberOfReps > 0 && animation.reps >= numberOfReps) {\n return true;\n }\n\n const startValue = reverse\n ? (nextAnimation.current as number)\n : animation.startValue;\n if (reverse) {\n nextAnimation.toValue = animation.startValue;\n animation.startValue = startValue;\n }\n nextAnimation.onStart(\n nextAnimation,\n startValue,\n now,\n nextAnimation.previousAnimation as RepeatAnimation\n );\n return false;\n }\n return false;\n }\n\n const repCallback = (finished: boolean): void => {\n if (callback) {\n callback(finished);\n }\n // when cancelled call inner animation's callback\n if (!finished && nextAnimation.callback) {\n nextAnimation.callback(false /* finished */);\n }\n };\n\n function onStart(\n animation: RepeatAnimation,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: RepeatAnimation\n ): void {\n animation.startValue = value;\n animation.reps = 0;\n nextAnimation.onStart(nextAnimation, value, now, previousAnimation);\n }\n\n return {\n isHigherOrder: true,\n onFrame: repeat,\n onStart,\n reps: 0,\n current: nextAnimation.current,\n callback: repCallback,\n startValue: 0,\n } as RepeatAnimation;\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_util","require","withRepeat","_nextAnimation","numberOfReps","arguments","length","undefined","reverse","callback","defineAnimation","nextAnimation","repeat","animation","now","finished","onFrame","current","reps","startValue","toValue","onStart","previousAnimation","repCallback","value","isHigherOrder"],"sources":["repeat.ts"],"sourcesContent":["import { defineAnimation } from './util';\nimport {\n Animation,\n AnimationCallback,\n AnimatableValue,\n Timestamp,\n} from '../commonTypes';\nimport { NextAnimation, RepeatAnimation } from './commonTypes';\n\nexport interface InnerRepeatAnimation\n extends Omit<RepeatAnimation, 'toValue' | 'startValue'> {\n toValue: number;\n startValue: number;\n}\n\nexport function withRepeat(\n _nextAnimation: NextAnimation<RepeatAnimation>,\n numberOfReps = 2,\n reverse = false,\n callback?: AnimationCallback\n): Animation<RepeatAnimation> {\n 'worklet';\n\n return defineAnimation<RepeatAnimation>(_nextAnimation, () => {\n 'worklet';\n\n const nextAnimation: RepeatAnimation =\n typeof _nextAnimation === 'function' ? _nextAnimation() : _nextAnimation;\n\n function repeat(animation: InnerRepeatAnimation, now: Timestamp): boolean {\n const finished = nextAnimation.onFrame(nextAnimation, now);\n animation.current = nextAnimation.current;\n if (finished) {\n animation.reps += 1;\n // call inner animation's callback on every repetition\n // as the second argument the animation's current value is passed\n if (nextAnimation.callback) {\n nextAnimation.callback(true /* finished */, animation.current);\n }\n if (numberOfReps > 0 && animation.reps >= numberOfReps) {\n return true;\n }\n\n const startValue = reverse\n ? (nextAnimation.current as number)\n : animation.startValue;\n if (reverse) {\n nextAnimation.toValue = animation.startValue;\n animation.startValue = startValue;\n }\n nextAnimation.onStart(\n nextAnimation,\n startValue,\n now,\n nextAnimation.previousAnimation as RepeatAnimation\n );\n return false;\n }\n return false;\n }\n\n const repCallback = (finished: boolean): void => {\n if (callback) {\n callback(finished);\n }\n // when cancelled call inner animation's callback\n if (!finished && nextAnimation.callback) {\n nextAnimation.callback(false /* finished */);\n }\n };\n\n function onStart(\n animation: RepeatAnimation,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: RepeatAnimation\n ): void {\n animation.startValue = value;\n animation.reps = 0;\n nextAnimation.onStart(nextAnimation, value, now, previousAnimation);\n }\n\n return {\n isHigherOrder: true,\n onFrame: repeat,\n onStart,\n reps: 0,\n current: nextAnimation.current,\n callback: repCallback,\n startValue: 0,\n } as RepeatAnimation;\n });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAeO,SAASC,UAAUA,CACxBC,cAA8C,EAIlB;EAC5B,SAAS;;EAAC,IAJVC,YAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAAA,IAChBG,OAAO,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAAA,IACfI,QAA4B,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CAAC,eAAe;MAC9C;IACF,CAAC;;IAED,SAASY,OAAOA,CACdR,SAA0B,EAC1BW,KAAsB,EACtBV,GAAc,EACdQ,iBAAkC,EAC5B;MACNT,SAAS,CAACM,UAAU,GAAGK,KAAK;MAC5BX,SAAS,CAACK,IAAI,GAAG,CAAC;MAClBP,aAAa,CAACU,OAAO,CAACV,aAAa,EAAEa,KAAK,EAAEV,GAAG,EAAEQ,iBAAiB,CAAC;IACrE;IAEA,OAAO;MACLG,aAAa,EAAE,IAAI;MACnBT,OAAO,EAAEJ,MAAM;MACfS,OAAO;MACPH,IAAI,EAAE,CAAC;MACPD,OAAO,EAAEN,aAAa,CAACM,OAAO;MAC9BR,QAAQ,EAAEc,WAAW;MACrBJ,UAAU,EAAE;IACd,CAAC;EACH,CAAC,CAAC;AACJ"}
|
|
@@ -4,16 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.withSequence = withSequence;
|
|
7
|
-
|
|
8
7
|
var _util = require("./util");
|
|
9
|
-
|
|
10
8
|
function withSequence() {
|
|
11
9
|
'worklet';
|
|
12
10
|
|
|
13
11
|
for (var _len = arguments.length, _animations = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
14
12
|
_animations[_key] = arguments[_key];
|
|
15
13
|
}
|
|
16
|
-
|
|
17
14
|
return (0, _util.defineAnimation)(_animations[0], () => {
|
|
18
15
|
'worklet';
|
|
19
16
|
|
|
@@ -22,62 +19,48 @@ function withSequence() {
|
|
|
22
19
|
result.finished = false;
|
|
23
20
|
return result;
|
|
24
21
|
});
|
|
25
|
-
|
|
26
22
|
const firstAnimation = animations[0];
|
|
27
|
-
|
|
28
23
|
const callback = finished => {
|
|
29
24
|
if (finished) {
|
|
30
25
|
// we want to call the callback after every single animation
|
|
31
26
|
// not after all of them
|
|
32
27
|
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
}
|
|
29
|
+
// this is going to be called only if sequence has been cancelled
|
|
36
30
|
animations.forEach(animation => {
|
|
37
31
|
if (typeof animation.callback === 'function' && !animation.finished) {
|
|
38
32
|
animation.callback(finished);
|
|
39
33
|
}
|
|
40
34
|
});
|
|
41
35
|
};
|
|
42
|
-
|
|
43
36
|
function sequence(animation, now) {
|
|
44
37
|
const currentAnim = animations[animation.animationIndex];
|
|
45
38
|
const finished = currentAnim.onFrame(currentAnim, now);
|
|
46
39
|
animation.current = currentAnim.current;
|
|
47
|
-
|
|
48
40
|
if (finished) {
|
|
49
41
|
// we want to call the callback after every single animation
|
|
50
42
|
if (currentAnim.callback) {
|
|
51
|
-
currentAnim.callback(true
|
|
52
|
-
/* finished */
|
|
53
|
-
);
|
|
43
|
+
currentAnim.callback(true /* finished */);
|
|
54
44
|
}
|
|
55
45
|
|
|
56
46
|
currentAnim.finished = true;
|
|
57
47
|
animation.animationIndex += 1;
|
|
58
|
-
|
|
59
48
|
if (animation.animationIndex < animations.length) {
|
|
60
49
|
const nextAnim = animations[animation.animationIndex];
|
|
61
50
|
nextAnim.onStart(nextAnim, currentAnim.current, now, currentAnim);
|
|
62
51
|
return false;
|
|
63
52
|
}
|
|
64
|
-
|
|
65
53
|
return true;
|
|
66
54
|
}
|
|
67
|
-
|
|
68
55
|
return false;
|
|
69
56
|
}
|
|
70
|
-
|
|
71
57
|
function onStart(animation, value, now, previousAnimation) {
|
|
72
58
|
animation.animationIndex = 0;
|
|
73
|
-
|
|
74
59
|
if (previousAnimation === undefined) {
|
|
75
60
|
previousAnimation = animations[animations.length - 1];
|
|
76
61
|
}
|
|
77
|
-
|
|
78
62
|
firstAnimation.onStart(firstAnimation, value, now, previousAnimation);
|
|
79
63
|
}
|
|
80
|
-
|
|
81
64
|
return {
|
|
82
65
|
isHigherOrder: true,
|
|
83
66
|
onFrame: sequence,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withSequence","_animations","defineAnimation","animations","map","a","result","finished","firstAnimation","callback","forEach","animation","sequence","now","currentAnim","animationIndex","onFrame","current","
|
|
1
|
+
{"version":3,"names":["_util","require","withSequence","_len","arguments","length","_animations","Array","_key","defineAnimation","animations","map","a","result","finished","firstAnimation","callback","forEach","animation","sequence","now","currentAnim","animationIndex","onFrame","current","nextAnim","onStart","value","previousAnimation","undefined","isHigherOrder"],"sources":["sequence.ts"],"sourcesContent":["import { defineAnimation } from './util';\nimport { NextAnimation, SequenceAnimation } from './commonTypes';\nimport {\n Animation,\n AnimatableValue,\n AnimationObject,\n Timestamp,\n} from '../commonTypes';\n\nexport function withSequence(\n ..._animations: NextAnimation<AnimationObject>[]\n): Animation<SequenceAnimation> {\n 'worklet';\n return defineAnimation<SequenceAnimation>(\n _animations[0] as SequenceAnimation,\n () => {\n 'worklet';\n const animations = _animations.map((a) => {\n const result = typeof a === 'function' ? a() : a;\n result.finished = false;\n return result;\n });\n const firstAnimation = animations[0];\n\n const callback = (finished: boolean): void => {\n if (finished) {\n // we want to call the callback after every single animation\n // not after all of them\n return;\n }\n // this is going to be called only if sequence has been cancelled\n animations.forEach((animation) => {\n if (typeof animation.callback === 'function' && !animation.finished) {\n animation.callback(finished);\n }\n });\n };\n\n function sequence(animation: SequenceAnimation, now: Timestamp): boolean {\n const currentAnim = animations[animation.animationIndex];\n const finished = currentAnim.onFrame(currentAnim, now);\n animation.current = currentAnim.current;\n if (finished) {\n // we want to call the callback after every single animation\n if (currentAnim.callback) {\n currentAnim.callback(true /* finished */);\n }\n currentAnim.finished = true;\n animation.animationIndex += 1;\n if (animation.animationIndex < animations.length) {\n const nextAnim = animations[animation.animationIndex];\n nextAnim.onStart(nextAnim, currentAnim.current, now, currentAnim);\n return false;\n }\n return true;\n }\n return false;\n }\n\n function onStart(\n animation: SequenceAnimation,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: SequenceAnimation\n ): void {\n animation.animationIndex = 0;\n if (previousAnimation === undefined) {\n previousAnimation = animations[\n animations.length - 1\n ] as SequenceAnimation;\n }\n firstAnimation.onStart(firstAnimation, value, now, previousAnimation);\n }\n\n return {\n isHigherOrder: true,\n onFrame: sequence,\n onStart,\n animationIndex: 0,\n current: firstAnimation.current,\n callback,\n } as SequenceAnimation;\n }\n );\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AASO,SAASC,YAAYA,CAAA,EAEI;EAC9B,SAAS;;EAAC,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAFPC,WAAW,OAAAC,KAAA,CAAAJ,IAAA,GAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAXF,WAAW,CAAAE,IAAA,IAAAJ,SAAA,CAAAI,IAAA;EAAA;EAGd,OAAO,IAAAC,qBAAe,EACpBH,WAAW,CAAC,CAAC,CAAC,EACd,MAAM;IACJ,SAAS;;IACT,MAAMI,UAAU,GAAGJ,WAAW,CAACK,GAAG,CAAEC,CAAC,IAAK;MACxC,MAAMC,MAAM,GAAG,OAAOD,CAAC,KAAK,UAAU,GAAGA,CAAC,EAAE,GAAGA,CAAC;MAChDC,MAAM,CAACC,QAAQ,GAAG,KAAK;MACvB,OAAOD,MAAM;IACf,CAAC,CAAC;IACF,MAAME,cAAc,GAAGL,UAAU,CAAC,CAAC,CAAC;IAEpC,MAAMM,QAAQ,GAAIF,QAAiB,IAAW;MAC5C,IAAIA,QAAQ,EAAE;QACZ;QACA;QACA;MACF;MACA;MACAJ,UAAU,CAACO,OAAO,CAAEC,SAAS,IAAK;QAChC,IAAI,OAAOA,SAAS,CAACF,QAAQ,KAAK,UAAU,IAAI,CAACE,SAAS,CAACJ,QAAQ,EAAE;UACnEI,SAAS,CAACF,QAAQ,CAACF,QAAQ,CAAC;QAC9B;MACF,CAAC,CAAC;IACJ,CAAC;IAED,SAASK,QAAQA,CAACD,SAA4B,EAAEE,GAAc,EAAW;MACvE,MAAMC,WAAW,GAAGX,UAAU,CAACQ,SAAS,CAACI,cAAc,CAAC;MACxD,MAAMR,QAAQ,GAAGO,WAAW,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