react-native-reanimated 3.8.0 → 3.9.0-layout-animation-experimental
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/ShadowTreeCloner.cpp +5 -2
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.cpp +42 -32
- package/Common/cpp/LayoutAnimations/LayoutAnimationsManager.h +5 -7
- package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.cpp +565 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsProxy.h +74 -0
- package/Common/cpp/LayoutAnimations/LayoutAnimationsUtils.h +140 -0
- package/Common/cpp/NativeModules/NativeReanimatedModule.cpp +216 -58
- package/Common/cpp/NativeModules/NativeReanimatedModule.h +32 -11
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.cpp +2 -17
- package/Common/cpp/NativeModules/NativeReanimatedModuleSpec.h +6 -8
- package/Common/cpp/ReanimatedRuntime/RNRuntimeDecorator.cpp +3 -0
- package/Common/cpp/ReanimatedRuntime/WorkletRuntime.cpp +3 -4
- package/Common/cpp/ReanimatedRuntime/WorkletRuntimeDecorator.cpp +8 -3
- package/Common/cpp/SharedItems/Shareables.cpp +31 -5
- package/Common/cpp/SharedItems/Shareables.h +18 -2
- package/Common/cpp/Tools/JSScheduler.cpp +29 -5
- package/Common/cpp/Tools/JSScheduler.h +21 -4
- package/Common/cpp/Tools/PlatformDepMethodsHolder.h +6 -2
- package/Common/cpp/Tools/UIRuntimeDecorator.cpp +6 -0
- package/Common/cpp/Tools/UIRuntimeDecorator.h +1 -0
- package/android/CMakeLists.txt +3 -0
- package/android/build.gradle +17 -5
- package/android/src/main/cpp/NativeProxy.cpp +77 -12
- package/android/src/main/cpp/NativeProxy.h +35 -1
- package/android/src/main/java/com/swmansion/reanimated/NodesManager.java +58 -19
- package/android/src/main/java/com/swmansion/reanimated/ReanimatedPackage.java +7 -2
- package/android/src/{reactNativeVersionPatch/ReanimatedUIManager/latest → main/java}/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +5 -5
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/AnimationsManager.java +10 -6
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/ReanimatedNativeHierarchyManager.java +18 -1
- package/android/src/main/java/com/swmansion/reanimated/layoutReanimation/SharedTransitionManager.java +105 -17
- package/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensor.java +2 -1
- package/android/src/paper/java/com/swmansion/reanimated/NativeReanimatedModuleSpec.java +37 -0
- package/android/src/{main/java/com/swmansion/reanimated → reactNativeVersionPatch/ReanimatedUIManager/73/com/swmansion}/ReanimatedModule.java +4 -3
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/{70 → 73}/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +1 -22
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/ReanimatedModule.java +176 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/latest/com/swmansion/reanimated/layoutReanimation/ReanimatedUIManager.java +0 -26
- package/android/src/{fabric/java → reactNativeVersionPatch/RuntimeExecutor/73}/com/swmansion/reanimated/NativeProxy.java +16 -4
- package/android/src/reactNativeVersionPatch/RuntimeExecutor/latest/com/swmansion/reanimated/NativeProxy.java +143 -0
- package/apple/LayoutReanimation/REAAnimationsManager.h +3 -0
- package/apple/LayoutReanimation/REAAnimationsManager.m +11 -0
- package/apple/LayoutReanimation/REASharedTransitionManager.m +99 -23
- package/apple/LayoutReanimation/REASnapshot.h +1 -0
- package/apple/LayoutReanimation/REASnapshot.m +78 -37
- package/apple/REAModule.h +22 -2
- package/apple/REAModule.mm +97 -46
- package/apple/REANodesManager.h +3 -3
- package/apple/REANodesManager.mm +46 -22
- package/apple/native/NativeProxy.h +28 -2
- package/apple/native/NativeProxy.mm +65 -195
- package/apple/native/PlatformDepMethodsHolderImpl.h +59 -0
- package/apple/native/PlatformDepMethodsHolderImpl.mm +429 -0
- package/apple/sensor/ReanimatedSensor.m +5 -5
- package/lib/module/Animated.js.map +1 -1
- package/lib/module/ConfigHelper.js +1 -1
- package/lib/module/ConfigHelper.js.map +1 -1
- package/lib/module/animationBuilder.js +1 -0
- package/lib/module/animationBuilder.js.map +1 -1
- package/lib/module/createAnimatedComponent/InlinePropManager.js +4 -4
- package/lib/module/createAnimatedComponent/InlinePropManager.js.map +1 -1
- package/lib/module/createAnimatedComponent/JSPropsUpdater.js +9 -6
- package/lib/module/createAnimatedComponent/JSPropsUpdater.js.map +1 -1
- package/lib/module/createAnimatedComponent/JSPropsUpdater.web.js +11 -0
- package/lib/module/createAnimatedComponent/JSPropsUpdater.web.js.map +1 -0
- package/lib/module/createAnimatedComponent/PropsFilter.js +25 -9
- package/lib/module/createAnimatedComponent/PropsFilter.js.map +1 -1
- package/lib/module/createAnimatedComponent/commonTypes.js.map +1 -1
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js +83 -52
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
- package/lib/module/createAnimatedComponent/getViewInfo.js +37 -0
- package/lib/module/createAnimatedComponent/getViewInfo.js.map +1 -0
- package/lib/module/createAnimatedComponent/index.js.map +1 -1
- package/lib/module/createAnimatedComponent/setAndForwardRef.js +4 -5
- package/lib/module/createAnimatedComponent/setAndForwardRef.js.map +1 -1
- package/lib/module/createAnimatedComponent/utils.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +1 -2
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/mock.js +12 -12
- package/lib/module/mock.js.map +1 -1
- package/lib/module/propsAllowlists.js.map +1 -1
- package/lib/module/reanimated2/Bezier.js.map +1 -1
- package/lib/module/reanimated2/Colors.js +4 -11
- package/lib/module/reanimated2/Colors.js.map +1 -1
- package/lib/module/reanimated2/Easing.js +3 -7
- package/lib/module/reanimated2/Easing.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js +16 -13
- package/lib/module/reanimated2/NativeReanimated/NativeReanimated.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/index.js.map +1 -1
- package/lib/module/reanimated2/NativeReanimated/index.web.js.map +1 -1
- package/lib/module/reanimated2/PlatformChecker.js +2 -1
- package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
- package/lib/module/reanimated2/PropAdapters.js +1 -1
- package/lib/module/reanimated2/PropAdapters.js.map +1 -1
- package/lib/module/reanimated2/PropsRegistry.js +1 -2
- package/lib/module/reanimated2/PropsRegistry.js.map +1 -1
- package/lib/module/reanimated2/Sensor.js +2 -2
- package/lib/module/reanimated2/Sensor.js.map +1 -1
- package/lib/module/reanimated2/SensorContainer.js +2 -2
- package/lib/module/reanimated2/SensorContainer.js.map +1 -1
- package/lib/module/reanimated2/UpdateLayoutAnimations.js +30 -8
- package/lib/module/reanimated2/UpdateLayoutAnimations.js.map +1 -1
- package/lib/module/reanimated2/UpdateProps.js.map +1 -1
- package/lib/module/reanimated2/ViewDescriptorsSet.js.map +1 -1
- package/lib/module/reanimated2/WorkletEventHandler.js +74 -31
- package/lib/module/reanimated2/WorkletEventHandler.js.map +1 -1
- package/lib/module/reanimated2/animation/clamp.js.map +1 -1
- package/lib/module/reanimated2/animation/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/decay.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/index.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/rigidDecay.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/rubberBandDecay.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/utils.js.map +1 -1
- 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 +1 -6
- package/lib/module/reanimated2/animation/repeat.js.map +1 -1
- package/lib/module/reanimated2/animation/sequence.js +1 -5
- package/lib/module/reanimated2/animation/sequence.js.map +1 -1
- package/lib/module/reanimated2/animation/spring.js.map +1 -1
- package/lib/module/reanimated2/animation/springUtils.js +8 -10
- package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/styleAnimation.js +5 -4
- package/lib/module/reanimated2/animation/styleAnimation.js.map +1 -1
- package/lib/module/reanimated2/animation/timing.js +4 -1
- package/lib/module/reanimated2/animation/timing.js.map +1 -1
- package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js +1 -2
- package/lib/module/reanimated2/animation/transformationMatrix/matrixUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +22 -2
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +3 -1
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js +1 -0
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/component/Image.js +1 -0
- package/lib/module/reanimated2/component/Image.js.map +1 -1
- package/lib/module/reanimated2/component/LayoutAnimationConfig.js +1 -0
- package/lib/module/reanimated2/component/LayoutAnimationConfig.js.map +1 -1
- package/lib/module/reanimated2/component/PerformanceMonitor.js +169 -0
- package/lib/module/reanimated2/component/PerformanceMonitor.js.map +1 -0
- package/lib/module/reanimated2/component/ScrollView.js +1 -0
- package/lib/module/reanimated2/component/ScrollView.js.map +1 -1
- package/lib/module/reanimated2/component/Text.js +1 -0
- package/lib/module/reanimated2/component/Text.js.map +1 -1
- package/lib/module/reanimated2/component/View.js +1 -0
- package/lib/module/reanimated2/component/View.js.map +1 -1
- package/lib/module/reanimated2/core.js +6 -15
- package/lib/module/reanimated2/core.js.map +1 -1
- package/lib/module/reanimated2/errors.js +8 -8
- package/lib/module/reanimated2/errors.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.js +33 -8
- package/lib/module/reanimated2/fabricUtils.js.map +1 -1
- package/lib/module/reanimated2/fabricUtils.web.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js +2 -2
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryJS.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/FrameCallbackRegistryUI.js.map +1 -1
- package/lib/module/reanimated2/frameCallback/index.js.map +1 -1
- package/lib/module/reanimated2/globals.d.js.map +1 -1
- package/lib/module/reanimated2/helperTypes.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 +1 -0
- package/lib/module/reanimated2/hook/useAnimatedGestureHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js +3 -4
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedProps.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +1 -0
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +12 -7
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +3 -1
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +3 -6
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +3 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useEvent.js +4 -5
- package/lib/module/reanimated2/hook/useEvent.js.map +1 -1
- package/lib/module/reanimated2/hook/useFrameCallback.js +1 -2
- package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
- package/lib/module/reanimated2/hook/useHandler.js +3 -1
- package/lib/module/reanimated2/hook/useHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useReducedMotion.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +60 -16
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useWorkletCallback.js.map +1 -1
- package/lib/module/reanimated2/hook/utils.js.map +1 -1
- package/lib/module/reanimated2/index.js +2 -0
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/initializers.js +1 -5
- package/lib/module/reanimated2/initializers.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +2 -6
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/interpolation.js +1 -1
- package/lib/module/reanimated2/interpolation.js.map +1 -1
- package/lib/module/reanimated2/isSharedValue.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.js +3 -6
- package/lib/module/reanimated2/jestUtils.js.map +1 -1
- package/lib/module/reanimated2/jestUtils.web.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js +5 -9
- package/lib/module/reanimated2/js-reanimated/JSReanimated.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/WebSensor.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/index.js +2 -2
- package/lib/module/reanimated2/js-reanimated/index.js.map +1 -1
- package/lib/module/reanimated2/js-reanimated/react-native-web.d.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +4 -2
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +12 -11
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +12 -10
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- 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 +11 -4
- package/lib/module/reanimated2/layoutReanimation/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +22 -22
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +22 -22
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +26 -26
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +10 -10
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +6 -6
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +10 -10
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +18 -18
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +18 -18
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +10 -10
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +34 -34
- 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 +17 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +4 -4
- 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/ProgressTransitionManager.js +16 -12
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js +13 -7
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Bounce.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Fade.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Flip.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Lightspeed.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Pinwheel.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Roll.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Rotate.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Slide.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Stretch.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animation/Zoom.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animationParser.js +0 -2
- package/lib/module/reanimated2/layoutReanimation/web/animationParser.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/animationsManager.js +1 -2
- package/lib/module/reanimated2/layoutReanimation/web/animationsManager.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/componentStyle.js +3 -1
- package/lib/module/reanimated2/layoutReanimation/web/componentStyle.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/componentUtils.js +6 -7
- package/lib/module/reanimated2/layoutReanimation/web/componentUtils.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/config.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js +2 -2
- package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/domUtils.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/web/domUtils.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/index.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/transition/Fading.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/transition/Linear.web.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/transition/Sequenced.web.js.map +1 -1
- package/lib/module/reanimated2/mappers.js +2 -4
- package/lib/module/reanimated2/mappers.js.map +1 -1
- package/lib/module/reanimated2/mockedRequestAnimationFrame.js.map +1 -1
- package/lib/module/reanimated2/mutables.js +2 -4
- 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.map +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js +1 -1
- package/lib/module/reanimated2/platform-specific/jsVersion.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/dispatchCommand.js +2 -4
- package/lib/module/reanimated2/platformFunctions/dispatchCommand.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/dispatchCommand.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js +2 -2
- package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/index.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/measure.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/measure.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/scrollTo.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/scrollTo.web.js +1 -1
- package/lib/module/reanimated2/platformFunctions/scrollTo.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setGestureState.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setGestureState.web.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setNativeProps.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setNativeProps.web.js.map +1 -1
- package/lib/module/reanimated2/pluginUtils.js.map +1 -1
- package/lib/module/reanimated2/publicGlobals.js.map +1 -1
- package/lib/module/reanimated2/runtimes.js +11 -19
- package/lib/module/reanimated2/runtimes.js.map +1 -1
- package/lib/module/reanimated2/screenTransition/RNScreensTurboModule.js +20 -0
- package/lib/module/reanimated2/screenTransition/RNScreensTurboModule.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/animationManager.js +41 -0
- package/lib/module/reanimated2/screenTransition/animationManager.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/commonTypes.js +4 -0
- package/lib/module/reanimated2/screenTransition/commonTypes.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/index.js +5 -0
- package/lib/module/reanimated2/screenTransition/index.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/presets.js +157 -0
- package/lib/module/reanimated2/screenTransition/presets.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/styleUpdater.js +62 -0
- package/lib/module/reanimated2/screenTransition/styleUpdater.js.map +1 -0
- package/lib/module/reanimated2/screenTransition/swipeSimulator.js +190 -0
- package/lib/module/reanimated2/screenTransition/swipeSimulator.js.map +1 -0
- package/lib/module/reanimated2/shareableMappingCache.js.map +1 -1
- package/lib/module/reanimated2/shareables.js +27 -10
- package/lib/module/reanimated2/shareables.js.map +1 -1
- package/lib/module/reanimated2/threads.js +9 -34
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/module/reanimated2/valueSetter.js +1 -2
- package/lib/module/reanimated2/valueSetter.js.map +1 -1
- package/lib/module/reanimated2/valueUnpacker.js +4 -3
- package/lib/module/reanimated2/valueUnpacker.js.map +1 -1
- package/lib/module/specs/NativeReanimatedModule.js +5 -0
- package/lib/module/specs/NativeReanimatedModule.js.map +1 -0
- package/lib/typescript/ConfigHelper.d.ts +1 -0
- package/lib/typescript/createAnimatedComponent/InlinePropManager.d.ts +1 -1
- package/lib/typescript/createAnimatedComponent/JSPropsUpdater.web.d.ts +6 -0
- package/lib/typescript/createAnimatedComponent/PropsFilter.d.ts +3 -0
- package/lib/typescript/createAnimatedComponent/getViewInfo.d.ts +9 -0
- package/lib/typescript/reanimated2/NativeReanimated/NativeReanimated.d.ts +8 -13
- package/lib/typescript/reanimated2/UpdateLayoutAnimations.d.ts +12 -1
- package/lib/typescript/reanimated2/WorkletEventHandler.d.ts +16 -9
- package/lib/typescript/reanimated2/animation/util.d.ts +2 -0
- package/lib/typescript/reanimated2/component/LayoutAnimationConfig.d.ts +1 -1
- package/lib/typescript/reanimated2/component/PerformanceMonitor.d.ts +2 -0
- package/lib/typescript/reanimated2/core.d.ts +3 -4
- package/lib/typescript/reanimated2/hook/commonTypes.d.ts +6 -0
- package/lib/typescript/reanimated2/hook/useEvent.d.ts +2 -3
- package/lib/typescript/reanimated2/hook/useScrollViewOffset.d.ts +3 -1
- package/lib/typescript/reanimated2/index.d.ts +3 -0
- package/lib/typescript/reanimated2/js-reanimated/JSReanimated.d.ts +2 -2
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +2 -1
- package/lib/typescript/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.d.ts +2 -2
- package/lib/typescript/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.d.ts +2 -2
- package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
- package/lib/typescript/reanimated2/screenTransition/RNScreensTurboModule.d.ts +2 -0
- package/lib/typescript/reanimated2/screenTransition/animationManager.d.ts +3 -0
- package/lib/typescript/reanimated2/screenTransition/commonTypes.d.ts +38 -0
- package/lib/typescript/reanimated2/screenTransition/index.d.ts +3 -0
- package/lib/typescript/reanimated2/screenTransition/presets.d.ts +11 -0
- package/lib/typescript/reanimated2/screenTransition/styleUpdater.d.ts +3 -0
- package/lib/typescript/reanimated2/screenTransition/swipeSimulator.d.ts +2 -0
- package/lib/typescript/specs/NativeReanimatedModule.d.ts +6 -0
- package/package.json +29 -17
- package/plugin/build/plugin.js +7 -2
- package/src/ConfigHelper.ts +1 -1
- package/src/animationBuilder.tsx +2 -0
- package/src/createAnimatedComponent/InlinePropManager.ts +2 -2
- package/src/createAnimatedComponent/JSPropsUpdater.ts +7 -6
- package/src/createAnimatedComponent/JSPropsUpdater.web.ts +26 -0
- package/src/createAnimatedComponent/PropsFilter.tsx +31 -6
- package/src/createAnimatedComponent/createAnimatedComponent.tsx +108 -60
- package/src/createAnimatedComponent/getViewInfo.ts +39 -0
- package/src/mock.ts +13 -1
- package/src/reanimated2/NativeReanimated/NativeReanimated.ts +33 -35
- package/src/reanimated2/PlatformChecker.ts +3 -2
- package/src/reanimated2/PropsRegistry.ts +1 -3
- package/src/reanimated2/UpdateLayoutAnimations.ts +53 -13
- package/src/reanimated2/WorkletEventHandler.ts +98 -39
- package/src/reanimated2/animation/styleAnimation.ts +8 -6
- package/src/reanimated2/animation/timing.ts +9 -1
- package/src/reanimated2/animation/util.ts +28 -3
- package/src/reanimated2/commonTypes.ts +4 -1
- package/src/reanimated2/component/PerformanceMonitor.tsx +216 -0
- package/src/reanimated2/core.ts +9 -31
- package/src/reanimated2/errors.ts +1 -0
- package/src/reanimated2/fabricUtils.ts +43 -18
- package/src/reanimated2/globals.d.ts +11 -1
- package/src/reanimated2/hook/commonTypes.ts +10 -0
- package/src/reanimated2/hook/useAnimatedRef.ts +20 -11
- package/src/reanimated2/hook/useEvent.ts +4 -4
- package/src/reanimated2/hook/useScrollViewOffset.ts +94 -23
- package/src/reanimated2/index.ts +11 -0
- package/src/reanimated2/js-reanimated/JSReanimated.ts +7 -7
- package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +4 -0
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +9 -1
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +9 -1
- package/src/reanimated2/layoutReanimation/animationsManager.ts +10 -2
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +13 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/ProgressTransitionManager.ts +17 -8
- package/src/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.ts +26 -7
- package/src/reanimated2/layoutReanimation/web/animationsManager.ts +1 -1
- package/src/reanimated2/layoutReanimation/web/componentStyle.ts +3 -1
- package/src/reanimated2/layoutReanimation/web/componentUtils.ts +1 -1
- package/src/reanimated2/layoutReanimation/web/createAnimation.ts +2 -2
- package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
- package/src/reanimated2/platformFunctions/getRelativeCoords.ts +2 -2
- package/src/reanimated2/screenTransition/RNScreensTurboModule.ts +29 -0
- package/src/reanimated2/screenTransition/animationManager.ts +45 -0
- package/src/reanimated2/screenTransition/commonTypes.ts +63 -0
- package/src/reanimated2/screenTransition/index.ts +12 -0
- package/src/reanimated2/screenTransition/presets.ts +137 -0
- package/src/reanimated2/screenTransition/styleUpdater.ts +73 -0
- package/src/reanimated2/screenTransition/swipeSimulator.ts +238 -0
- package/src/reanimated2/shareables.ts +29 -6
- package/src/reanimated2/valueUnpacker.ts +10 -3
- package/src/specs/NativeReanimatedModule.ts +9 -0
- package/android/src/reactNativeVersionPatch/ReanimatedUIManager/70/com/swmansion/reanimated/ReanimatedUIManagerFactory.java +0 -16
- package/android/src/reactNativeVersionPatch/messageQueueThread/67/com/swmansion/reanimated/ReanimatedMessageQueueThread.java +0 -12
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
4
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
3
5
|
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; }
|
|
4
|
-
function _toPropertyKey(
|
|
5
|
-
function _toPrimitive(
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
9
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
10
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
6
11
|
import { registerEventHandler, unregisterEventHandler } from './core';
|
|
7
12
|
import { shouldBeUseWeb } from './PlatformChecker';
|
|
8
13
|
const SHOULD_BE_USE_WEB = shouldBeUseWeb();
|
|
@@ -17,45 +22,83 @@ function jsListener(eventName, handler) {
|
|
|
17
22
|
});
|
|
18
23
|
};
|
|
19
24
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
var _viewTags = /*#__PURE__*/new WeakMap();
|
|
26
|
+
var _registrations = /*#__PURE__*/new WeakMap();
|
|
27
|
+
class WorkletEventHandlerNative {
|
|
28
|
+
// keys are viewTags, values are arrays of registration ID's for each viewTag
|
|
29
|
+
constructor(worklet, eventNames) {
|
|
24
30
|
_defineProperty(this, "eventNames", void 0);
|
|
25
|
-
_defineProperty(this, "
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
_defineProperty(this, "registrations", void 0);
|
|
31
|
+
_defineProperty(this, "worklet", void 0);
|
|
32
|
+
_classPrivateFieldInitSpec(this, _viewTags, void 0);
|
|
33
|
+
_classPrivateFieldInitSpec(this, _registrations, void 0);
|
|
29
34
|
this.worklet = worklet;
|
|
30
35
|
this.eventNames = eventNames;
|
|
31
|
-
this
|
|
32
|
-
this
|
|
33
|
-
this.viewTag = undefined;
|
|
34
|
-
this.registrations = [];
|
|
35
|
-
if (SHOULD_BE_USE_WEB) {
|
|
36
|
-
this.listeners = eventNames.reduce((acc, eventName) => {
|
|
37
|
-
acc[eventName] = jsListener(eventName, worklet);
|
|
38
|
-
return acc;
|
|
39
|
-
}, {});
|
|
40
|
-
}
|
|
36
|
+
_classPrivateFieldSet(_viewTags, this, new Set());
|
|
37
|
+
_classPrivateFieldSet(_registrations, this, new Map());
|
|
41
38
|
}
|
|
42
|
-
|
|
39
|
+
updateEventHandler(newWorklet, newEvents) {
|
|
40
|
+
// Update worklet and event names
|
|
43
41
|
this.worklet = newWorklet;
|
|
44
|
-
this.
|
|
42
|
+
this.eventNames = newEvents;
|
|
43
|
+
|
|
44
|
+
// Detach all events
|
|
45
|
+
_classPrivateFieldGet(_registrations, this).forEach(registrationIDs => {
|
|
46
|
+
registrationIDs.forEach(id => unregisterEventHandler(id));
|
|
47
|
+
// No need to remove registrationIDs from map, since it gets overwritten when attaching
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Attach new events with new worklet
|
|
51
|
+
Array.from(_classPrivateFieldGet(_viewTags, this)).forEach(tag => {
|
|
52
|
+
const newRegistrations = this.eventNames.map(eventName => registerEventHandler(this.worklet, eventName, tag));
|
|
53
|
+
_classPrivateFieldGet(_registrations, this).set(tag, newRegistrations);
|
|
54
|
+
});
|
|
45
55
|
}
|
|
46
56
|
registerForEvents(viewTag, fallbackEventName) {
|
|
47
|
-
this.viewTag
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
_classPrivateFieldGet(_viewTags, this).add(viewTag);
|
|
58
|
+
const newRegistrations = this.eventNames.map(eventName => registerEventHandler(this.worklet, eventName, viewTag));
|
|
59
|
+
_classPrivateFieldGet(_registrations, this).set(viewTag, newRegistrations);
|
|
60
|
+
if (this.eventNames.length === 0 && fallbackEventName) {
|
|
61
|
+
const newRegistration = registerEventHandler(this.worklet, fallbackEventName, viewTag);
|
|
62
|
+
_classPrivateFieldGet(_registrations, this).set(viewTag, [newRegistration]);
|
|
51
63
|
}
|
|
52
64
|
}
|
|
53
|
-
|
|
54
|
-
|
|
65
|
+
unregisterFromEvents(viewTag) {
|
|
66
|
+
var _classPrivateFieldGet2;
|
|
67
|
+
_classPrivateFieldGet(_viewTags, this).delete(viewTag);
|
|
68
|
+
(_classPrivateFieldGet2 = _classPrivateFieldGet(_registrations, this).get(viewTag)) === null || _classPrivateFieldGet2 === void 0 || _classPrivateFieldGet2.forEach(id => {
|
|
69
|
+
unregisterEventHandler(id);
|
|
70
|
+
});
|
|
71
|
+
_classPrivateFieldGet(_registrations, this).delete(viewTag);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
class WorkletEventHandlerWeb {
|
|
75
|
+
constructor(worklet, eventNames = []) {
|
|
76
|
+
_defineProperty(this, "eventNames", void 0);
|
|
77
|
+
_defineProperty(this, "listeners", void 0);
|
|
78
|
+
_defineProperty(this, "worklet", void 0);
|
|
79
|
+
this.worklet = worklet;
|
|
80
|
+
this.eventNames = eventNames;
|
|
81
|
+
this.listeners = {};
|
|
82
|
+
this.setupWebListeners();
|
|
83
|
+
}
|
|
84
|
+
setupWebListeners() {
|
|
85
|
+
this.listeners = {};
|
|
86
|
+
this.eventNames.forEach(eventName => {
|
|
87
|
+
this.listeners[eventName] = jsListener(eventName, this.worklet);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
updateEventHandler(newWorklet, newEvents) {
|
|
91
|
+
// Update worklet and event names
|
|
92
|
+
this.worklet = newWorklet;
|
|
93
|
+
this.eventNames = newEvents;
|
|
94
|
+
this.setupWebListeners();
|
|
95
|
+
}
|
|
96
|
+
registerForEvents(_viewTag, _fallbackEventName) {
|
|
97
|
+
// noop
|
|
55
98
|
}
|
|
56
|
-
unregisterFromEvents() {
|
|
57
|
-
|
|
58
|
-
this.registrations = [];
|
|
99
|
+
unregisterFromEvents(_viewTag) {
|
|
100
|
+
// noop
|
|
59
101
|
}
|
|
60
102
|
}
|
|
103
|
+
export const WorkletEventHandler = SHOULD_BE_USE_WEB ? WorkletEventHandlerWeb : WorkletEventHandlerNative;
|
|
61
104
|
//# sourceMappingURL=WorkletEventHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_classPrivateFieldInitSpec","obj","privateMap","value","_checkPrivateRedeclaration","set","privateCollection","has","TypeError","_defineProperty","key","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","String","Number","_classPrivateFieldGet","s","a","get","_assertClassBrand","_classPrivateFieldSet","n","arguments","length","registerEventHandler","unregisterEventHandler","shouldBeUseWeb","SHOULD_BE_USE_WEB","jsListener","eventName","handler","evt","nativeEvent","_viewTags","WeakMap","_registrations","WorkletEventHandlerNative","constructor","worklet","eventNames","Set","Map","updateEventHandler","newWorklet","newEvents","forEach","registrationIDs","id","Array","from","tag","newRegistrations","map","registerForEvents","viewTag","fallbackEventName","add","newRegistration","unregisterFromEvents","_classPrivateFieldGet2","delete","WorkletEventHandlerWeb","listeners","setupWebListeners","_viewTag","_fallbackEventName","WorkletEventHandler"],"sources":["WorkletEventHandler.ts"],"sourcesContent":["'use strict';\nimport type { NativeSyntheticEvent } from 'react-native';\nimport { registerEventHandler, unregisterEventHandler } from './core';\nimport type {\n EventPayload,\n ReanimatedEvent,\n IWorkletEventHandler,\n} from './hook/commonTypes';\nimport { shouldBeUseWeb } from './PlatformChecker';\n\nconst SHOULD_BE_USE_WEB = shouldBeUseWeb();\n\ntype JSEvent<Event extends object> = NativeSyntheticEvent<EventPayload<Event>>;\n\n// In JS implementation (e.g. for web) we don't use Reanimated's\n// event emitter, therefore we have to handle here\n// the event that came from React Native and convert it.\nfunction jsListener<Event extends object>(\n eventName: string,\n handler: (event: ReanimatedEvent<Event>) => void\n) {\n return (evt: JSEvent<Event>) => {\n handler({ ...evt.nativeEvent, eventName } as ReanimatedEvent<Event>);\n };\n}\n\nclass WorkletEventHandlerNative<Event extends object>\n implements IWorkletEventHandler<Event>\n{\n eventNames: string[];\n worklet: (event: ReanimatedEvent<Event>) => void;\n #viewTags: Set<number>;\n #registrations: Map<number, number[]>; // keys are viewTags, values are arrays of registration ID's for each viewTag\n constructor(\n worklet: (event: ReanimatedEvent<Event>) => void,\n eventNames: string[]\n ) {\n this.worklet = worklet;\n this.eventNames = eventNames;\n this.#viewTags = new Set<number>();\n this.#registrations = new Map<number, number[]>();\n }\n\n updateEventHandler(\n newWorklet: (event: ReanimatedEvent<Event>) => void,\n newEvents: string[]\n ): void {\n // Update worklet and event names\n this.worklet = newWorklet;\n this.eventNames = newEvents;\n\n // Detach all events\n this.#registrations.forEach((registrationIDs) => {\n registrationIDs.forEach((id) => unregisterEventHandler(id));\n // No need to remove registrationIDs from map, since it gets overwritten when attaching\n });\n\n // Attach new events with new worklet\n Array.from(this.#viewTags).forEach((tag) => {\n const newRegistrations = this.eventNames.map((eventName) =>\n registerEventHandler(this.worklet, eventName, tag)\n );\n this.#registrations.set(tag, newRegistrations);\n });\n }\n\n registerForEvents(viewTag: number, fallbackEventName?: string): void {\n this.#viewTags.add(viewTag);\n\n const newRegistrations = this.eventNames.map((eventName) =>\n registerEventHandler(this.worklet, eventName, viewTag)\n );\n this.#registrations.set(viewTag, newRegistrations);\n\n if (this.eventNames.length === 0 && fallbackEventName) {\n const newRegistration = registerEventHandler(\n this.worklet,\n fallbackEventName,\n viewTag\n );\n this.#registrations.set(viewTag, [newRegistration]);\n }\n }\n\n unregisterFromEvents(viewTag: number): void {\n this.#viewTags.delete(viewTag);\n this.#registrations.get(viewTag)?.forEach((id) => {\n unregisterEventHandler(id);\n });\n this.#registrations.delete(viewTag);\n }\n}\n\nclass WorkletEventHandlerWeb<Event extends object>\n implements IWorkletEventHandler<Event>\n{\n eventNames: string[];\n listeners:\n | Record<string, (event: ReanimatedEvent<ReanimatedEvent<Event>>) => void>\n | Record<string, (event: JSEvent<Event>) => void>;\n\n worklet: (event: ReanimatedEvent<Event>) => void;\n\n constructor(\n worklet: (event: ReanimatedEvent<Event>) => void,\n eventNames: string[] = []\n ) {\n this.worklet = worklet;\n this.eventNames = eventNames;\n this.listeners = {};\n this.setupWebListeners();\n }\n\n setupWebListeners() {\n this.listeners = {};\n this.eventNames.forEach((eventName) => {\n this.listeners[eventName] = jsListener(eventName, this.worklet);\n });\n }\n\n updateEventHandler(\n newWorklet: (event: ReanimatedEvent<Event>) => void,\n newEvents: string[]\n ): void {\n // Update worklet and event names\n this.worklet = newWorklet;\n this.eventNames = newEvents;\n this.setupWebListeners();\n }\n\n registerForEvents(_viewTag: number, _fallbackEventName?: string): void {\n // noop\n }\n\n unregisterFromEvents(_viewTag: number): void {\n // noop\n }\n}\n\nexport const WorkletEventHandler = SHOULD_BE_USE_WEB\n ? WorkletEventHandlerWeb\n : WorkletEventHandlerNative;\n"],"mappings":"AAAA,YAAY;;AAAC,SAAAA,2BAAAC,GAAA,EAAAC,UAAA,EAAAC,KAAA,IAAAC,0BAAA,CAAAH,GAAA,EAAAC,UAAA,GAAAA,UAAA,CAAAG,GAAA,CAAAJ,GAAA,EAAAE,KAAA;AAAA,SAAAC,2BAAAH,GAAA,EAAAK,iBAAA,QAAAA,iBAAA,CAAAC,GAAA,CAAAN,GAAA,eAAAO,SAAA;AAAA,SAAAC,gBAAAR,GAAA,EAAAS,GAAA,EAAAP,KAAA,IAAAO,GAAA,GAAAC,cAAA,CAAAD,GAAA,OAAAA,GAAA,IAAAT,GAAA,IAAAW,MAAA,CAAAC,cAAA,CAAAZ,GAAA,EAAAS,GAAA,IAAAP,KAAA,EAAAA,KAAA,EAAAW,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAf,GAAA,CAAAS,GAAA,IAAAP,KAAA,WAAAF,GAAA;AAAA,SAAAU,eAAAM,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAF,CAAA,uCAAAC,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAF,CAAA,EAAAG,CAAA,2BAAAH,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAI,CAAA,GAAAJ,CAAA,CAAAK,MAAA,CAAAC,WAAA,kBAAAF,CAAA,QAAAH,CAAA,GAAAG,CAAA,CAAAG,IAAA,CAAAP,CAAA,EAAAG,CAAA,uCAAAF,CAAA,SAAAA,CAA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,UAAU;IACzB,IAAI,CAACJ,UAAU,GAAGK,SAAS;IAC3B,IAAI,CAACmB,iBAAiB,CAAC,CAAC;EAC1B;EAEAV,iBAAiBA,CAACW,QAAgB,EAAEC,kBAA2B,EAAQ;IACrE;EAAA;EAGFP,oBAAoBA,CAACM,QAAgB,EAAQ;IAC3C;EAAA;AAEJ;AAEA,OAAO,MAAME,mBAAmB,GAAGvC,iBAAiB,GAChDkC,sBAAsB,GACtBzB,yBAAyB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defineAnimation","getReduceMotionForAnimation","recognizePrefixSuffix","withClamp","config","_animationToClamp","animationToClamp","strippedMin","min","undefined","strippedValue","strippedMax","max","clampOnFrame","animation","now","finished","onFrame","current","console","warn","prefix","suffix","newValue","onStart","value","previousAnimation","animationBeforeClamped","callback","isHigherOrder","reduceMotion"],"sources":["clamp.ts"],"sourcesContent":["'use strict';\nimport {\n defineAnimation,\n getReduceMotionForAnimation,\n recognizePrefixSuffix,\n} from './util';\nimport type {\n Animation,\n Timestamp,\n AnimatableValue,\n AnimationObject,\n ReduceMotion,\n} from '../commonTypes';\nimport type { ClampAnimation } from './commonTypes';\n\ntype withClampType = <T extends number | string>(\n config: {\n min?: T;\n max?: T;\n },\n clampedAnimation: T\n) => T;\n\nexport const withClamp = function <T extends number | string>(\n config: { min?: T; max?: T; reduceMotion?: ReduceMotion },\n _animationToClamp: AnimationObject<T> | (() => AnimationObject<T>)\n): Animation<ClampAnimation> {\n 'worklet';\n return defineAnimation<ClampAnimation, AnimationObject<T>>(\n _animationToClamp,\n (): ClampAnimation => {\n 'worklet';\n const animationToClamp =\n typeof _animationToClamp === 'function'\n ? _animationToClamp()\n : _animationToClamp;\n\n const strippedMin =\n config.min === undefined\n ? undefined\n : recognizePrefixSuffix(config.min).strippedValue;\n\n const strippedMax =\n config.max === undefined\n ? undefined\n : recognizePrefixSuffix(config.max).strippedValue;\n\n function clampOnFrame(\n animation: ClampAnimation,\n now: Timestamp\n ): boolean {\n const finished = animationToClamp.onFrame(animationToClamp, now);\n\n if (animationToClamp.current === undefined) {\n console.warn(\n \"[Reanimated] Error inside 'withClamp' animation, the inner animation has invalid current value\"\n );\n return true;\n } else {\n const { prefix, strippedValue, suffix } = recognizePrefixSuffix(\n animationToClamp.current\n );\n\n let newValue;\n\n if (strippedMax !== undefined && strippedMax < strippedValue) {\n newValue = strippedMax;\n } else if (strippedMin !== undefined && strippedMin > strippedValue) {\n newValue = strippedMin;\n } else {\n newValue = strippedValue;\n }\n\n animation.current =\n typeof animationToClamp.current === 'number'\n ? newValue\n : `${prefix === undefined ? '' : prefix}${newValue}${\n suffix === undefined ? '' : suffix\n }`;\n }\n\n return finished;\n }\n\n function onStart(\n animation: Animation<any>,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: Animation<any> | null\n ): void {\n animation.current = value;\n animation.previousAnimation = animationToClamp;\n const animationBeforeClamped = previousAnimation?.previousAnimation;\n if (\n config.max !== undefined &&\n config.min !== undefined &&\n config.max < config.min\n ) {\n console.warn(\n '[Reanimated] Wrong config was provided to withClamp. Min value is bigger than max'\n );\n }\n\n animationToClamp.onStart(\n animationToClamp,\n /** provide the current value of the previous animation of the clamped animation \n so we can animate from the original \"un-truncated\" value\n */\n animationBeforeClamped?.current || value,\n now,\n animationBeforeClamped\n );\n }\n\n const callback = (finished?: boolean): void => {\n if (animationToClamp.callback) {\n animationToClamp.callback(finished);\n }\n };\n\n return {\n isHigherOrder: true,\n onFrame: clampOnFrame,\n onStart,\n current: animationToClamp.current!,\n callback,\n previousAnimation: null,\n reduceMotion: getReduceMotionForAnimation(config.reduceMotion),\n };\n }\n );\n} as withClampType;\n"],"mappings":"AAAA,YAAY;;AACZ,SACEA,eAAe,EACfC,2BAA2B,EAC3BC,qBAAqB,QAChB,QAAQ;AAkBf,OAAO,MAAMC,SAAS,GAAG,SAAAA,CACvBC,MAAyD,EACzDC,iBAAkE,EACvC;EAC3B,SAAS;;EACT,OAAOL,eAAe,CACpBK,iBAAiB,EACjB,MAAsB;IACpB,SAAS;;IACT,MAAMC,gBAAgB,GACpB,OAAOD,iBAAiB,KAAK,UAAU,GACnCA,iBAAiB,
|
|
1
|
+
{"version":3,"names":["defineAnimation","getReduceMotionForAnimation","recognizePrefixSuffix","withClamp","config","_animationToClamp","animationToClamp","strippedMin","min","undefined","strippedValue","strippedMax","max","clampOnFrame","animation","now","finished","onFrame","current","console","warn","prefix","suffix","newValue","onStart","value","previousAnimation","animationBeforeClamped","callback","isHigherOrder","reduceMotion"],"sources":["clamp.ts"],"sourcesContent":["'use strict';\nimport {\n defineAnimation,\n getReduceMotionForAnimation,\n recognizePrefixSuffix,\n} from './util';\nimport type {\n Animation,\n Timestamp,\n AnimatableValue,\n AnimationObject,\n ReduceMotion,\n} from '../commonTypes';\nimport type { ClampAnimation } from './commonTypes';\n\ntype withClampType = <T extends number | string>(\n config: {\n min?: T;\n max?: T;\n },\n clampedAnimation: T\n) => T;\n\nexport const withClamp = function <T extends number | string>(\n config: { min?: T; max?: T; reduceMotion?: ReduceMotion },\n _animationToClamp: AnimationObject<T> | (() => AnimationObject<T>)\n): Animation<ClampAnimation> {\n 'worklet';\n return defineAnimation<ClampAnimation, AnimationObject<T>>(\n _animationToClamp,\n (): ClampAnimation => {\n 'worklet';\n const animationToClamp =\n typeof _animationToClamp === 'function'\n ? _animationToClamp()\n : _animationToClamp;\n\n const strippedMin =\n config.min === undefined\n ? undefined\n : recognizePrefixSuffix(config.min).strippedValue;\n\n const strippedMax =\n config.max === undefined\n ? undefined\n : recognizePrefixSuffix(config.max).strippedValue;\n\n function clampOnFrame(\n animation: ClampAnimation,\n now: Timestamp\n ): boolean {\n const finished = animationToClamp.onFrame(animationToClamp, now);\n\n if (animationToClamp.current === undefined) {\n console.warn(\n \"[Reanimated] Error inside 'withClamp' animation, the inner animation has invalid current value\"\n );\n return true;\n } else {\n const { prefix, strippedValue, suffix } = recognizePrefixSuffix(\n animationToClamp.current\n );\n\n let newValue;\n\n if (strippedMax !== undefined && strippedMax < strippedValue) {\n newValue = strippedMax;\n } else if (strippedMin !== undefined && strippedMin > strippedValue) {\n newValue = strippedMin;\n } else {\n newValue = strippedValue;\n }\n\n animation.current =\n typeof animationToClamp.current === 'number'\n ? newValue\n : `${prefix === undefined ? '' : prefix}${newValue}${\n suffix === undefined ? '' : suffix\n }`;\n }\n\n return finished;\n }\n\n function onStart(\n animation: Animation<any>,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: Animation<any> | null\n ): void {\n animation.current = value;\n animation.previousAnimation = animationToClamp;\n const animationBeforeClamped = previousAnimation?.previousAnimation;\n if (\n config.max !== undefined &&\n config.min !== undefined &&\n config.max < config.min\n ) {\n console.warn(\n '[Reanimated] Wrong config was provided to withClamp. Min value is bigger than max'\n );\n }\n\n animationToClamp.onStart(\n animationToClamp,\n /** provide the current value of the previous animation of the clamped animation \n so we can animate from the original \"un-truncated\" value\n */\n animationBeforeClamped?.current || value,\n now,\n animationBeforeClamped\n );\n }\n\n const callback = (finished?: boolean): void => {\n if (animationToClamp.callback) {\n animationToClamp.callback(finished);\n }\n };\n\n return {\n isHigherOrder: true,\n onFrame: clampOnFrame,\n onStart,\n current: animationToClamp.current!,\n callback,\n previousAnimation: null,\n reduceMotion: getReduceMotionForAnimation(config.reduceMotion),\n };\n }\n );\n} as withClampType;\n"],"mappings":"AAAA,YAAY;;AACZ,SACEA,eAAe,EACfC,2BAA2B,EAC3BC,qBAAqB,QAChB,QAAQ;AAkBf,OAAO,MAAMC,SAAS,GAAG,SAAAA,CACvBC,MAAyD,EACzDC,iBAAkE,EACvC;EAC3B,SAAS;;EACT,OAAOL,eAAe,CACpBK,iBAAiB,EACjB,MAAsB;IACpB,SAAS;;IACT,MAAMC,gBAAgB,GACpB,OAAOD,iBAAiB,KAAK,UAAU,GACnCA,iBAAiB,CAAC,CAAC,GACnBA,iBAAiB;IAEvB,MAAME,WAAW,GACfH,MAAM,CAACI,GAAG,KAAKC,SAAS,GACp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AAiB,GAAGpB,gBAAgB;MAC9C,MAAMqB,sBAAsB,GAAGD,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAEA,iBAAiB;MACnE,IACEtB,MAAM,CAACQ,GAAG,KAAKH,SAAS,IACxBL,MAAM,CAACI,GAAG,KAAKC,SAAS,IACxBL,MAAM,CAACQ,GAAG,GAAGR,MAAM,CAACI,GAAG,EACvB;QACAW,OAAO,CAACC,IAAI,CACV,mFACF,CAAC;MACH;MAEAd,gBAAgB,CAACkB,OAAO,CACtBlB,gBAAgB;MAChB;AACV;AACA;MACU,CAAAqB,sBAAsB,aAAtBA,sBAAsB,uBAAtBA,sBAAsB,CAAET,OAAO,KAAIO,KAAK,EACxCV,GAAG,EACHY,sBACF,CAAC;IACH;IAEA,MAAMC,QAAQ,GAAIZ,QAAkB,IAAW;MAC7C,IAAIV,gBAAgB,CAACsB,QAAQ,EAAE;QAC7BtB,gBAAgB,CAACsB,QAAQ,CAACZ,QAAQ,CAAC;MACrC;IACF,CAAC;IAED,OAAO;MACLa,aAAa,EAAE,IAAI;MACnBZ,OAAO,EAAEJ,YAAY;MACrBW,OAAO;MACPN,OAAO,EAAEZ,gBAAgB,CAACY,OAAQ;MAClCU,QAAQ;MACRF,iBAAiB,EAAE,IAAI;MACvBI,YAAY,EAAE7B,2BAA2B,CAACG,MAAM,CAAC0B,YAAY;IAC/D,CAAC;EACH,CACF,CAAC;AACH,CAAkB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["'use strict';\nimport type {\n StyleProps,\n AnimatableValue,\n AnimationObject,\n Animation,\n Timestamp,\n AnimationCallback,\n} from '../commonTypes';\nimport type { AnimatedStyle } from '../helperTypes';\n\nexport interface HigherOrderAnimation {\n isHigherOrder?: boolean;\n}\n\nexport type NextAnimation<T extends AnimationObject> = T | (() => T);\n\nexport interface ClampAnimation\n extends Animation<ClampAnimation>,\n HigherOrderAnimation {\n current: AnimatableValue;\n}\n\nexport interface DelayAnimation\n extends Animation<DelayAnimation>,\n HigherOrderAnimation {\n startTime: Timestamp;\n started: boolean;\n previousAnimation: DelayAnimation | null;\n current: AnimatableValue;\n}\n\nexport interface RepeatAnimation\n extends Animation<RepeatAnimation>,\n HigherOrderAnimation {\n reps: number;\n startValue: AnimatableValue;\n toValue?: AnimatableValue;\n previousAnimation?: RepeatAnimation;\n}\n\nexport interface SequenceAnimation\n extends Animation<SequenceAnimation>,\n HigherOrderAnimation {\n animationIndex: number;\n}\n\nexport interface StyleLayoutAnimation extends HigherOrderAnimation {\n current: StyleProps;\n styleAnimations: AnimatedStyle<any>;\n onFrame: (animation: StyleLayoutAnimation, timestamp: Timestamp) => boolean;\n onStart: (\n nextAnimation: StyleLayoutAnimation,\n current: AnimatedStyle<any>,\n timestamp: Timestamp,\n previousAnimation: StyleLayoutAnimation\n ) => void;\n callback?: AnimationCallback;\n}\n"],"mappings":"AAAA,YAAY;;AAAC"}
|
|
1
|
+
{"version":3,"names":[],"sources":["commonTypes.ts"],"sourcesContent":["'use strict';\nimport type {\n StyleProps,\n AnimatableValue,\n AnimationObject,\n Animation,\n Timestamp,\n AnimationCallback,\n} from '../commonTypes';\nimport type { AnimatedStyle } from '../helperTypes';\n\nexport interface HigherOrderAnimation {\n isHigherOrder?: boolean;\n}\n\nexport type NextAnimation<T extends AnimationObject> = T | (() => T);\n\nexport interface ClampAnimation\n extends Animation<ClampAnimation>,\n HigherOrderAnimation {\n current: AnimatableValue;\n}\n\nexport interface DelayAnimation\n extends Animation<DelayAnimation>,\n HigherOrderAnimation {\n startTime: Timestamp;\n started: boolean;\n previousAnimation: DelayAnimation | null;\n current: AnimatableValue;\n}\n\nexport interface RepeatAnimation\n extends Animation<RepeatAnimation>,\n HigherOrderAnimation {\n reps: number;\n startValue: AnimatableValue;\n toValue?: AnimatableValue;\n previousAnimation?: RepeatAnimation;\n}\n\nexport interface SequenceAnimation\n extends Animation<SequenceAnimation>,\n HigherOrderAnimation {\n animationIndex: number;\n}\n\nexport interface StyleLayoutAnimation extends HigherOrderAnimation {\n current: StyleProps;\n styleAnimations: AnimatedStyle<any>;\n onFrame: (animation: StyleLayoutAnimation, timestamp: Timestamp) => boolean;\n onStart: (\n nextAnimation: StyleLayoutAnimation,\n current: AnimatedStyle<any>,\n timestamp: Timestamp,\n previousAnimation: StyleLayoutAnimation\n ) => void;\n callback?: AnimationCallback;\n}\n"],"mappings":"AAAA,YAAY;;AAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defineAnimation","getReduceMotionForAnimation","rubberBandDecay","isValidRubberBandConfig","rigidDecay","validateConfig","config","clamp","Array","isArray","Error","length","velocityFactor","rubberBandEffect","withDecay","userConfig","callback","deceleration","velocity","rubberBandFactor","Object","keys","forEach","key","decay","animation","now","onStart","value","current","lastTimestamp","startTimestamp","initialVelocity","reduceMotion","onFrame"],"sources":["decay.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from '../util';\nimport type {\n AnimationCallback,\n Timestamp,\n Animation,\n} from '../../commonTypes';\nimport { rubberBandDecay } from './rubberBandDecay';\nimport { isValidRubberBandConfig } from './utils';\nimport type {\n DecayAnimation,\n DecayConfig,\n DefaultDecayConfig,\n InnerDecayAnimation,\n} from './utils';\nimport { rigidDecay } from './rigidDecay';\n\nexport type WithDecayConfig = DecayConfig;\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withDecayType = (\n userConfig: DecayConfig,\n callback?: AnimationCallback\n) => number;\n\nfunction validateConfig(config: DefaultDecayConfig): void {\n 'worklet';\n if (config.clamp) {\n if (!Array.isArray(config.clamp)) {\n throw new Error(\n `[Reanimated] \\`config.clamp\\` must be an array but is ${typeof config.clamp}.`\n );\n }\n if (config.clamp.length !== 2) {\n throw new Error(\n `[Reanimated] \\`clamp array\\` must contain 2 items but is given ${\n config.clamp.length as number\n }.`\n );\n }\n }\n if (config.velocityFactor <= 0) {\n throw new Error(\n `[Reanimated] \\`config.velocityFactor\\` must be greather then 0 but is ${config.velocityFactor}.`\n );\n }\n if (config.rubberBandEffect && !config.clamp) {\n throw new Error(\n '[Reanimated] You need to set `clamp` property when using `rubberBandEffect`.'\n );\n }\n}\n\n/**\n * Lets you create animations that mimic objects in motion with friction.\n *\n * @param config - The decay animation configuration - {@link DecayConfig}.\n * @param callback - A function called upon animation completion - {@link AnimationCallback}.\n * @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withDecay\n */\nexport const withDecay = function (\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 decay: (animation: InnerDecayAnimation, now: number) => boolean =\n isValidRubberBandConfig(config)\n ? (animation, now) => rubberBandDecay(animation, now, config)\n : (animation, now) => rigidDecay(animation, now, config);\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(config);\n\n if (animation.reduceMotion && config.clamp) {\n if (value < config.clamp[0]) {\n animation.current = config.clamp[0];\n } else if (value > config.clamp[1]) {\n animation.current = config.clamp[1];\n }\n }\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 reduceMotion: getReduceMotionForAnimation(config.reduceMotion),\n } as DecayAnimation;\n });\n} as unknown as withDecayType;\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,SAAS;AAMtE,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,uBAAuB,QAAQ,SAAS;AAOjD,SAASC,UAAU,QAAQ,cAAc;;AAIzC;;AAMA,SAASC,cAAcA,CAACC,MAA0B,EAAQ;EACxD,SAAS;;EACT,IAAIA,MAAM,CAACC,KAAK,EAAE;IAChB,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,MAAM,CAACC,KAAK,CAAC,EAAE;MAChC,MAAM,IAAIG,KAAK,CACZ,yDAAwD,OAAOJ,MAAM,CAACC,KAAM,
|
|
1
|
+
{"version":3,"names":["defineAnimation","getReduceMotionForAnimation","rubberBandDecay","isValidRubberBandConfig","rigidDecay","validateConfig","config","clamp","Array","isArray","Error","length","velocityFactor","rubberBandEffect","withDecay","userConfig","callback","deceleration","velocity","rubberBandFactor","Object","keys","forEach","key","decay","animation","now","onStart","value","current","lastTimestamp","startTimestamp","initialVelocity","reduceMotion","onFrame"],"sources":["decay.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from '../util';\nimport type {\n AnimationCallback,\n Timestamp,\n Animation,\n} from '../../commonTypes';\nimport { rubberBandDecay } from './rubberBandDecay';\nimport { isValidRubberBandConfig } from './utils';\nimport type {\n DecayAnimation,\n DecayConfig,\n DefaultDecayConfig,\n InnerDecayAnimation,\n} from './utils';\nimport { rigidDecay } from './rigidDecay';\n\nexport type WithDecayConfig = DecayConfig;\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withDecayType = (\n userConfig: DecayConfig,\n callback?: AnimationCallback\n) => number;\n\nfunction validateConfig(config: DefaultDecayConfig): void {\n 'worklet';\n if (config.clamp) {\n if (!Array.isArray(config.clamp)) {\n throw new Error(\n `[Reanimated] \\`config.clamp\\` must be an array but is ${typeof config.clamp}.`\n );\n }\n if (config.clamp.length !== 2) {\n throw new Error(\n `[Reanimated] \\`clamp array\\` must contain 2 items but is given ${\n config.clamp.length as number\n }.`\n );\n }\n }\n if (config.velocityFactor <= 0) {\n throw new Error(\n `[Reanimated] \\`config.velocityFactor\\` must be greather then 0 but is ${config.velocityFactor}.`\n );\n }\n if (config.rubberBandEffect && !config.clamp) {\n throw new Error(\n '[Reanimated] You need to set `clamp` property when using `rubberBandEffect`.'\n );\n }\n}\n\n/**\n * Lets you create animations that mimic objects in motion with friction.\n *\n * @param config - The decay animation configuration - {@link DecayConfig}.\n * @param callback - A function called upon animation completion - {@link AnimationCallback}.\n * @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withDecay\n */\nexport const withDecay = function (\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 decay: (animation: InnerDecayAnimation, now: number) => boolean =\n isValidRubberBandConfig(config)\n ? (animation, now) => rubberBandDecay(animation, now, config)\n : (animation, now) => rigidDecay(animation, now, config);\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(config);\n\n if (animation.reduceMotion && config.clamp) {\n if (value < config.clamp[0]) {\n animation.current = config.clamp[0];\n } else if (value > config.clamp[1]) {\n animation.current = config.clamp[1];\n }\n }\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 reduceMotion: getReduceMotionForAnimation(config.reduceMotion),\n } as DecayAnimation;\n });\n} as unknown as withDecayType;\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,SAAS;AAMtE,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,uBAAuB,QAAQ,SAAS;AAOjD,SAASC,UAAU,QAAQ,cAAc;;AAIzC;;AAMA,SAASC,cAAcA,CAACC,MAA0B,EAAQ;EACxD,SAAS;;EACT,IAAIA,MAAM,CAACC,KAAK,EAAE;IAChB,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,MAAM,CAACC,KAAK,CAAC,EAAE;MAChC,MAAM,IAAIG,KAAK,CACZ,yDAAwD,OAAOJ,MAAM,CAACC,KAAM,GAC/E,CAAC;IACH;IACA,IAAID,MAAM,CAACC,KAAK,CAACI,MAAM,KAAK,CAAC,EAAE;MAC7B,MAAM,IAAID,KAAK,CACZ,kEACCJ,MAAM,CAACC,KAAK,CAACI,MACd,GACH,CAAC;IACH;EACF;EACA,IAAIL,MAAM,CAACM,cAAc,IAAI,CAAC,EAAE;IAC9B,MAAM,IAAIF,KAAK,CACZ,yEAAwEJ,MAAM,CAACM,cAAe,GACjG,CAAC;EACH;EACA,IAAIN,MAAM,CAACO,gBAAgB,IAAI,CAACP,MAAM,CAACC,KAAK,EAAE;IAC5C,MAAM,IAAIG,KAAK,CACb,8EACF,CAAC;EACH;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,SAAS,GAAG,SAAAA,CACvBC,UAAuB,EACvBC,QAA4B,EACD;EAC3B,SAAS;;EAET,OAAOhB,eAAe,CAAiB,CAAC,EAAE,MAAM;IAC9C,SAAS;;IACT,MAAMM,MAA0B,GAAG;MACjCW,YAAY,EAAE,KAAK;MACnBL,cAAc,EAAE,CAAC;MACjBM,QAAQ,EAAE,CAAC;MACXC,gBAAgB,EAAE;IACpB,CAAC;IACD,IAAIJ,UAAU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,CAAC;MAChBC,cAAc,EAAE,CAAC;MACjBE,YAAY,EAAEhC,2BAA2B,CAACK,MAAM,CAAC2B,YAAY;IAC/D,CAAC;EACH,CAAC,CAAC;AACJ,CAA6B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withDecay"],"sources":["index.ts"],"sourcesContent":["'use strict';\nexport type { WithDecayConfig } from './decay';\nexport { withDecay } from './decay';\nexport type { DecayAnimation } from './utils';\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,SAAS,QAAQ,SAAS"}
|
|
1
|
+
{"version":3,"names":["withDecay"],"sources":["index.ts"],"sourcesContent":["'use strict';\nexport type { WithDecayConfig } from './decay';\nexport { withDecay } from './decay';\nexport type { DecayAnimation } from './utils';\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,SAAS,QAAQ,SAAS","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SLOPE_FACTOR","VELOCITY_EPS","rigidDecay","animation","now","config","lastTimestamp","startTimestamp","initialVelocity","current","velocity","deltaTime","Math","min","v","exp","deceleration","velocityFactor","clamp","abs"],"sources":["rigidDecay.ts"],"sourcesContent":["'use strict';\nimport { SLOPE_FACTOR, VELOCITY_EPS } from './utils';\nimport type { DefaultDecayConfig, InnerDecayAnimation } from './utils';\n\nexport function rigidDecay(\n animation: InnerDecayAnimation,\n now: number,\n config: DefaultDecayConfig\n): boolean {\n 'worklet';\n const { lastTimestamp, startTimestamp, initialVelocity, current, 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 = 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 (initialVelocity > 0 && animation.current >= config.clamp[1]) {\n animation.current = config.clamp[1];\n return true;\n }\n }\n return Math.abs(v) < VELOCITY_EPS;\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,YAAY,EAAEC,YAAY,QAAQ,SAAS;AAGpD,OAAO,SAASC,UAAUA,CACxBC,SAA8B,EAC9BC,GAAW,EACXC,MAA0B,EACjB;EACT,SAAS;;EACT,MAAM;IAAEC,aAAa;IAAEC,cAAc;IAAEC,eAAe;IAAEC,OAAO;IAAEC;EAAS,CAAC,GACzEP,SAAS;EAEX,MAAMQ,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACT,GAAG,GAAGE,aAAa,EAAE,EAAE,CAAC;EACnD,MAAMQ,CAAC,GACLJ,QAAQ,GACRE,IAAI,CAACG,GAAG,CACN,EAAE,CAAC,GAAGV,MAAM,CAACW,YAAY,CAAC,IAAIZ,GAAG,GAAGG,cAAc,CAAC,GAAGP,
|
|
1
|
+
{"version":3,"names":["SLOPE_FACTOR","VELOCITY_EPS","rigidDecay","animation","now","config","lastTimestamp","startTimestamp","initialVelocity","current","velocity","deltaTime","Math","min","v","exp","deceleration","velocityFactor","clamp","abs"],"sources":["rigidDecay.ts"],"sourcesContent":["'use strict';\nimport { SLOPE_FACTOR, VELOCITY_EPS } from './utils';\nimport type { DefaultDecayConfig, InnerDecayAnimation } from './utils';\n\nexport function rigidDecay(\n animation: InnerDecayAnimation,\n now: number,\n config: DefaultDecayConfig\n): boolean {\n 'worklet';\n const { lastTimestamp, startTimestamp, initialVelocity, current, 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 = 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 (initialVelocity > 0 && animation.current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GAAG,CAACL,CAAC,CAAC,GAAGb,YAAY;AACnC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SLOPE_FACTOR","VELOCITY_EPS","DERIVATIVE_EPS","rubberBandDecay","animation","now","config","lastTimestamp","startTimestamp","current","velocity","deltaTime","Math","min","clampIndex","abs","clamp","derivative","v","exp","deceleration","rubberBandFactor","springActive","velocityFactor"],"sources":["rubberBandDecay.ts"],"sourcesContent":["'use strict';\nimport type { RubberBandDecayConfig, InnerDecayAnimation } from './utils';\nimport { SLOPE_FACTOR, VELOCITY_EPS } from './utils';\n\nconst DERIVATIVE_EPS = 0.1;\n\nexport function rubberBandDecay(\n animation: InnerDecayAnimation,\n now: number,\n config: RubberBandDecayConfig\n): boolean {\n 'worklet';\n const { lastTimestamp, startTimestamp, current, velocity } = animation;\n\n const deltaTime = Math.min(now - lastTimestamp, 64);\n const clampIndex =\n Math.abs(current - config.clamp[0]) < Math.abs(current - config.clamp[1])\n ? 0\n : 1;\n\n let derivative = 0;\n if (current < config.clamp[0] || current > config.clamp[1]) {\n derivative = current - config.clamp[clampIndex];\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 if (Math.abs(derivative) > DERIVATIVE_EPS) {\n animation.springActive = true;\n } else if (animation.springActive) {\n animation.current = config.clamp[clampIndex];\n return true;\n } else if (Math.abs(v) < VELOCITY_EPS) {\n return true;\n }\n\n animation.current = current + (v * config.velocityFactor * deltaTime) / 1000;\n animation.velocity = v;\n animation.lastTimestamp = now;\n return false;\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,YAAY,EAAEC,YAAY,QAAQ,SAAS;AAEpD,MAAMC,cAAc,GAAG,GAAG;AAE1B,OAAO,SAASC,eAAeA,CAC7BC,SAA8B,EAC9BC,GAAW,EACXC,MAA6B,EACpB;EACT,SAAS;;EACT,MAAM;IAAEC,aAAa;IAAEC,cAAc;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAAGN,SAAS;EAEtE,MAAMO,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACR,GAAG,GAAGE,aAAa,EAAE,EAAE,CAAC;EACnD,MAAMO,UAAU,GACdF,IAAI,CAACG,GAAG,CAACN,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,CAAC,GAAGJ,IAAI,CAACG,GAAG,CAACN,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,CAAC,GACrE,CAAC,GACD,CAAC;EAEP,IAAIC,UAAU,GAAG,CAAC;EAClB,IAAIR,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,IAAIP,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,EAAE;IAC1DC,UAAU,GAAGR,OAAO,GAAGH,MAAM,CAACU,KAAK,CAACF,UAAU,CAAC;EACjD;EAEA,MAAMI,CAAC,GACLR,QAAQ,GACNE,IAAI,CAACO,GAAG,CACN,EAAE,CAAC,GAAGb,MAAM,CAACc,YAAY,CAAC,IAAIf,GAAG,GAAGG,cAAc,CAAC,GAAGR,
|
|
1
|
+
{"version":3,"names":["SLOPE_FACTOR","VELOCITY_EPS","DERIVATIVE_EPS","rubberBandDecay","animation","now","config","lastTimestamp","startTimestamp","current","velocity","deltaTime","Math","min","clampIndex","abs","clamp","derivative","v","exp","deceleration","rubberBandFactor","springActive","velocityFactor"],"sources":["rubberBandDecay.ts"],"sourcesContent":["'use strict';\nimport type { RubberBandDecayConfig, InnerDecayAnimation } from './utils';\nimport { SLOPE_FACTOR, VELOCITY_EPS } from './utils';\n\nconst DERIVATIVE_EPS = 0.1;\n\nexport function rubberBandDecay(\n animation: InnerDecayAnimation,\n now: number,\n config: RubberBandDecayConfig\n): boolean {\n 'worklet';\n const { lastTimestamp, startTimestamp, current, velocity } = animation;\n\n const deltaTime = Math.min(now - lastTimestamp, 64);\n const clampIndex =\n Math.abs(current - config.clamp[0]) < Math.abs(current - config.clamp[1])\n ? 0\n : 1;\n\n let derivative = 0;\n if (current < config.clamp[0] || current > config.clamp[1]) {\n derivative = current - config.clamp[clampIndex];\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 if (Math.abs(derivative) > DERIVATIVE_EPS) {\n animation.springActive = true;\n } else if (animation.springActive) {\n animation.current = config.clamp[clampIndex];\n return true;\n } else if (Math.abs(v) < VELOCITY_EPS) {\n return true;\n }\n\n animation.current = current + (v * config.velocityFactor * deltaTime) / 1000;\n animation.velocity = v;\n animation.lastTimestamp = now;\n return false;\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,SAASA,YAAY,EAAEC,YAAY,QAAQ,SAAS;AAEpD,MAAMC,cAAc,GAAG,GAAG;AAE1B,OAAO,SAASC,eAAeA,CAC7BC,SAA8B,EAC9BC,GAAW,EACXC,MAA6B,EACpB;EACT,SAAS;;EACT,MAAM;IAAEC,aAAa;IAAEC,cAAc;IAAEC,OAAO;IAAEC;EAAS,CAAC,GAAGN,SAAS;EAEtE,MAAMO,SAAS,GAAGC,IAAI,CAACC,GAAG,CAACR,GAAG,GAAGE,aAAa,EAAE,EAAE,CAAC;EACnD,MAAMO,UAAU,GACdF,IAAI,CAACG,GAAG,CAACN,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,CAAC,GAAGJ,IAAI,CAACG,GAAG,CAACN,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,CAAC,GACrE,CAAC,GACD,CAAC;EAEP,IAAIC,UAAU,GAAG,CAAC;EAClB,IAAIR,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,IAAIP,OAAO,GAAGH,MAAM,CAACU,KAAK,CAAC,CAAC,CAAC,EAAE;IAC1DC,UAAU,GAAGR,OAAO,GAAGH,MAAM,CAACU,KAAK,CAACF,UAAU,CAAC;EACjD;EAEA,MAAMI,CAAC,GACLR,QAAQ,GACNE,IAAI,CAACO,GAAG,CACN,EAAE,CAAC,GAAGb,MAAM,CAACc,YAAY,CAAC,IAAIf,GAAG,GAAGG,cAAc,CAAC,GAAGR,YACxD,CAAC,GACHiB,UAAU,GAAGX,MAAM,CAACe,gBAAgB;EAEtC,IAAIT,IAAI,CAACG,GAAG,CAACE,UAAU,CAAC,GAAGf,cAAc,EAAE;IACzCE,SAAS,CAACkB,YAAY,GAAG,IAAI;EAC/B,CAAC,MAAM,IAAIlB,SAAS,CAACkB,YAAY,EAAE;IACjClB,SAAS,CAACK,OAAO,GAAGH,MAAM,CAACU,KAAK,CAACF,UAAU,CAAC;IAC5C,OAAO,IAAI;EACb,CAAC,MAAM,IAAIF,IAAI,CAACG,GAAG,CAACG,CAAC,CAAC,GAAGjB,YAAY,EAAE;IACrC,OAAO,IAAI;EACb;EAEAG,SAAS,CAACK,OAAO,GAAGA,OAAO,GAAIS,CAAC,GAAGZ,MAAM,CAACiB,cAAc,GAAGZ,SAAS,GAAI,IAAI;EAC5EP,SAAS,CAACM,QAAQ,GAAGQ,CAAC;EACtBd,SAAS,CAACG,aAAa,GAAGF,GAAG;EAC7B,OAAO,KAAK;AACd","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isWeb","IS_WEB","VELOCITY_EPS","SLOPE_FACTOR","isValidRubberBandConfig","config","rubberBandEffect","Array","isArray","clamp","length"],"sources":["utils.ts"],"sourcesContent":["'use strict';\nimport type {\n AnimatableValue,\n AnimationObject,\n Animation,\n ReduceMotion,\n Timestamp,\n RequiredKeys,\n} from '../../../reanimated2/commonTypes';\nimport { isWeb } from '../../PlatformChecker';\n\nconst IS_WEB = isWeb();\nexport const VELOCITY_EPS = IS_WEB ? 1 / 20 : 1;\nexport const SLOPE_FACTOR = 0.1;\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 springActive?: boolean;\n}\n\n/**\n * The decay animation configuration.\n *\n * @param velocity - Initial velocity of the animation. Defaults to 0.\n * @param deceleration - The rate at which the velocity decreases over time. Defaults to 0.998.\n * @param clamp - Array of two numbers which restricts animation's range. Defaults to [].\n * @param velocityFactor - Velocity multiplier. Defaults to 1.\n * @param rubberBandEffect - Makes the animation bounce over the limit specified in `clamp`. Defaults to `false`.\n * @param rubberBandFactor - Strength of the rubber band effect. Defaults to 0.6.\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withDecay#config\n */\nexport type DecayConfig = {\n deceleration?: number;\n velocityFactor?: number;\n velocity?: number;\n reduceMotion?: ReduceMotion;\n} & (\n | {\n rubberBandEffect?: false;\n clamp?: [min: number, max: number];\n }\n | {\n rubberBandEffect: true;\n clamp: [min: number, max: number];\n rubberBandFactor?: number;\n }\n);\n\nexport type DefaultDecayConfig = RequiredKeys<\n DecayConfig,\n 'deceleration' | 'velocityFactor' | 'velocity'\n> & { rubberBandFactor: number };\n\n// If user wants to use rubber band decay animation we have to make sure he has provided clamp\nexport type RubberBandDecayConfig = RequiredKeys<\n DefaultDecayConfig,\n 'clamp'\n> & { rubberBandEffect: true };\n\nexport function isValidRubberBandConfig(\n config: DefaultDecayConfig\n): config is RubberBandDecayConfig {\n 'worklet';\n return (\n !!config.rubberBandEffect &&\n Array.isArray(config.clamp) &&\n config.clamp.length === 2\n );\n}\n"],"mappings":"AAAA,YAAY;;AASZ,SAASA,KAAK,QAAQ,uBAAuB;AAE7C,MAAMC,MAAM,GAAGD,KAAK,
|
|
1
|
+
{"version":3,"names":["isWeb","IS_WEB","VELOCITY_EPS","SLOPE_FACTOR","isValidRubberBandConfig","config","rubberBandEffect","Array","isArray","clamp","length"],"sources":["utils.ts"],"sourcesContent":["'use strict';\nimport type {\n AnimatableValue,\n AnimationObject,\n Animation,\n ReduceMotion,\n Timestamp,\n RequiredKeys,\n} from '../../../reanimated2/commonTypes';\nimport { isWeb } from '../../PlatformChecker';\n\nconst IS_WEB = isWeb();\nexport const VELOCITY_EPS = IS_WEB ? 1 / 20 : 1;\nexport const SLOPE_FACTOR = 0.1;\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 springActive?: boolean;\n}\n\n/**\n * The decay animation configuration.\n *\n * @param velocity - Initial velocity of the animation. Defaults to 0.\n * @param deceleration - The rate at which the velocity decreases over time. Defaults to 0.998.\n * @param clamp - Array of two numbers which restricts animation's range. Defaults to [].\n * @param velocityFactor - Velocity multiplier. Defaults to 1.\n * @param rubberBandEffect - Makes the animation bounce over the limit specified in `clamp`. Defaults to `false`.\n * @param rubberBandFactor - Strength of the rubber band effect. Defaults to 0.6.\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withDecay#config\n */\nexport type DecayConfig = {\n deceleration?: number;\n velocityFactor?: number;\n velocity?: number;\n reduceMotion?: ReduceMotion;\n} & (\n | {\n rubberBandEffect?: false;\n clamp?: [min: number, max: number];\n }\n | {\n rubberBandEffect: true;\n clamp: [min: number, max: number];\n rubberBandFactor?: number;\n }\n);\n\nexport type DefaultDecayConfig = RequiredKeys<\n DecayConfig,\n 'deceleration' | 'velocityFactor' | 'velocity'\n> & { rubberBandFactor: number };\n\n// If user wants to use rubber band decay animation we have to make sure he has provided clamp\nexport type RubberBandDecayConfig = RequiredKeys<\n DefaultDecayConfig,\n 'clamp'\n> & { rubberBandEffect: true };\n\nexport function isValidRubberBandConfig(\n config: DefaultDecayConfig\n): config is RubberBandDecayConfig {\n 'worklet';\n return (\n !!config.rubberBandEffect &&\n Array.isArray(config.clamp) &&\n config.clamp.length === 2\n );\n}\n"],"mappings":"AAAA,YAAY;;AASZ,SAASA,KAAK,QAAQ,uBAAuB;AAE7C,MAAMC,MAAM,GAAGD,KAAK,CAAC,CAAC;AACtB,OAAO,MAAME,YAAY,GAAGD,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC;AAC/C,OAAO,MAAME,YAAY,GAAG,GAAG;;AAiB/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBA;;AAMA,OAAO,SAASC,uBAAuBA,CACrCC,MAA0B,EACO;EACjC,SAAS;;EACT,OACE,CAAC,CAACA,MAAM,CAACC,gBAAgB,IACzBC,KAAK,CAACC,OAAO,CAACH,MAAM,CAACI,KAAK,CAAC,IAC3BJ,MAAM,CAACI,KAAK,CAACC,MAAM,KAAK,CAAC;AAE7B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withDelay","delayMs","_nextAnimation","reduceMotion","nextAnimation","delay","animation","now","startTime","started","previousAnimation","current","onStart","finished","onFrame","value","undefined","callback","isHigherOrder"],"sources":["delay.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type {\n Animation,\n Timestamp,\n AnimatableValue,\n AnimationObject,\n ReduceMotion,\n} from '../commonTypes';\nimport type { DelayAnimation } from './commonTypes';\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withDelayType = <T extends AnimatableValue>(\n delayMs: number,\n delayedAnimation: T,\n reduceMotion?: ReduceMotion\n) => T;\n\n/**\n * An animation modifier that lets you start an animation with a delay.\n *\n * @param delayMs - Duration (in milliseconds) before the animation starts.\n * @param nextAnimation - The animation to delay.\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\n * @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withDelay\n */\nexport const withDelay = function <T extends AnimationObject>(\n delayMs: number,\n _nextAnimation: T | (() => T),\n reduceMotion?: ReduceMotion\n): Animation<DelayAnimation> {\n 'worklet';\n return defineAnimation<DelayAnimation, T>(\n _nextAnimation,\n (): DelayAnimation => {\n 'worklet';\n const nextAnimation =\n typeof _nextAnimation === 'function'\n ? _nextAnimation()\n : _nextAnimation;\n\n function delay(animation: DelayAnimation, now: Timestamp): boolean {\n const { startTime, started, previousAnimation } = animation;\n const current: AnimatableValue = animation.current;\n\n if (now - startTime > delayMs || animation.reduceMotion) {\n if (!started) {\n nextAnimation.onStart(\n nextAnimation,\n current,\n now,\n previousAnimation!\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: Animation<any>,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: Animation<any> | null\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 // child animations inherit the setting, unless they already have it defined\n // they will have it defined only if the user used the `reduceMotion` prop\n if (nextAnimation.reduceMotion === undefined) {\n nextAnimation.reduceMotion = animation.reduceMotion;\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 reduceMotion: getReduceMotionForAnimation(reduceMotion),\n };\n }\n );\n} as withDelayType;\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;;AAUrE;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAG,SAAAA,CACvBC,OAAe,EACfC,cAA6B,EAC7BC,YAA2B,EACA;EAC3B,SAAS;;EACT,OAAOL,eAAe,CACpBI,cAAc,EACd,MAAsB;IACpB,SAAS;;IACT,MAAME,aAAa,GACjB,OAAOF,cAAc,KAAK,UAAU,GAChCA,cAAc,
|
|
1
|
+
{"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withDelay","delayMs","_nextAnimation","reduceMotion","nextAnimation","delay","animation","now","startTime","started","previousAnimation","current","onStart","finished","onFrame","value","undefined","callback","isHigherOrder"],"sources":["delay.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type {\n Animation,\n Timestamp,\n AnimatableValue,\n AnimationObject,\n ReduceMotion,\n} from '../commonTypes';\nimport type { DelayAnimation } from './commonTypes';\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withDelayType = <T extends AnimatableValue>(\n delayMs: number,\n delayedAnimation: T,\n reduceMotion?: ReduceMotion\n) => T;\n\n/**\n * An animation modifier that lets you start an animation with a delay.\n *\n * @param delayMs - Duration (in milliseconds) before the animation starts.\n * @param nextAnimation - The animation to delay.\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\n * @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withDelay\n */\nexport const withDelay = function <T extends AnimationObject>(\n delayMs: number,\n _nextAnimation: T | (() => T),\n reduceMotion?: ReduceMotion\n): Animation<DelayAnimation> {\n 'worklet';\n return defineAnimation<DelayAnimation, T>(\n _nextAnimation,\n (): DelayAnimation => {\n 'worklet';\n const nextAnimation =\n typeof _nextAnimation === 'function'\n ? _nextAnimation()\n : _nextAnimation;\n\n function delay(animation: DelayAnimation, now: Timestamp): boolean {\n const { startTime, started, previousAnimation } = animation;\n const current: AnimatableValue = animation.current;\n\n if (now - startTime > delayMs || animation.reduceMotion) {\n if (!started) {\n nextAnimation.onStart(\n nextAnimation,\n current,\n now,\n previousAnimation!\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: Animation<any>,\n value: AnimatableValue,\n now: Timestamp,\n previousAnimation: Animation<any> | null\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 // child animations inherit the setting, unless they already have it defined\n // they will have it defined only if the user used the `reduceMotion` prop\n if (nextAnimation.reduceMotion === undefined) {\n nextAnimation.reduceMotion = animation.reduceMotion;\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 reduceMotion: getReduceMotionForAnimation(reduceMotion),\n };\n }\n );\n} as withDelayType;\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BA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AAOA,CACdN,SAAyB,EACzBS,KAAsB,EACtBR,GAAc,EACdG,iBAAwC,EAClC;MACNJ,SAAS,CAACE,SAAS,GAAGD,GAAG;MACzBD,SAAS,CAACG,OAAO,GAAG,KAAK;MACzBH,SAAS,CAACK,OAAO,GAAGI,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;;MAEA;MACA;MACA,IAAIN,aAAa,CAACD,YAAY,KAAKa,SAAS,EAAE;QAC5CZ,aAAa,CAACD,YAAY,GAAGG,SAAS,CAACH,YAAY;MACrD;IACF;IAEA,MAAMc,QAAQ,GAAIJ,QAAkB,IAAW;MAC7C,IAAIT,aAAa,CAACa,QAAQ,EAAE;QAC1Bb,aAAa,CAACa,QAAQ,CAACJ,QAAQ,CAAC;MAClC;IACF,CAAC;IAED,OAAO;MACLK,aAAa,EAAE,IAAI;MACnBJ,OAAO,EAAET,KAAK;MACdO,OAAO;MACPD,OAAO,EAAEP,aAAa,CAACO,OAAQ;MAC/BM,QAAQ;MACRP,iBAAiB,EAAE,IAAI;MACvBF,SAAS,EAAE,CAAC;MACZC,OAAO,EAAE,KAAK;MACdN,YAAY,EAAEJ,2BAA2B,CAACI,YAAY;IACxD,CAAC;EACH,CACF,CAAC;AACH,CAAkB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["cancelAnimation","defineAnimation","initialUpdaterRun","withTiming","withSpring","withDecay","withClamp","withDelay","withRepeat","withSequence","withStyleAnimation"],"sources":["index.ts"],"sourcesContent":["'use strict';\nexport 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, WithTimingConfig } from './timing';\nexport { withSpring } from './spring';\nexport type { SpringAnimation, WithSpringConfig } from './springUtils';\nexport { withDecay } from './decay';\nexport type { DecayAnimation, WithDecayConfig } from './decay';\nexport { withClamp } from './clamp';\nexport { withDelay } from './delay';\nexport { withRepeat } from './repeat';\nexport { withSequence } from './sequence';\nexport { withStyleAnimation } from './styleAnimation';\n"],"mappings":"AAAA,YAAY;;AASZ,SAASA,eAAe,EAAEC,eAAe,EAAEC,iBAAiB,QAAQ,QAAQ;AAC5E,SAASC,UAAU,QAAQ,UAAU;AAErC,SAASC,UAAU,QAAQ,UAAU;AAErC,SAASC,SAAS,QAAQ,SAAS;AAEnC,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,YAAY,QAAQ,YAAY;AACzC,SAASC,kBAAkB,QAAQ,kBAAkB"}
|
|
1
|
+
{"version":3,"names":["cancelAnimation","defineAnimation","initialUpdaterRun","withTiming","withSpring","withDecay","withClamp","withDelay","withRepeat","withSequence","withStyleAnimation"],"sources":["index.ts"],"sourcesContent":["'use strict';\nexport 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, WithTimingConfig } from './timing';\nexport { withSpring } from './spring';\nexport type { SpringAnimation, WithSpringConfig } from './springUtils';\nexport { withDecay } from './decay';\nexport type { DecayAnimation, WithDecayConfig } from './decay';\nexport { withClamp } from './clamp';\nexport { withDelay } from './delay';\nexport { withRepeat } from './repeat';\nexport { withSequence } from './sequence';\nexport { withStyleAnimation } from './styleAnimation';\n"],"mappings":"AAAA,YAAY;;AASZ,SAASA,eAAe,EAAEC,eAAe,EAAEC,iBAAiB,QAAQ,QAAQ;AAC5E,SAASC,UAAU,QAAQ,UAAU;AAErC,SAASC,UAAU,QAAQ,UAAU;AAErC,SAASC,SAAS,QAAQ,SAAS;AAEnC,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,YAAY,QAAQ,YAAY;AACzC,SAASC,kBAAkB,QAAQ,kBAAkB","ignoreList":[]}
|
|
@@ -15,13 +15,9 @@ import { defineAnimation, getReduceMotionForAnimation } from './util';
|
|
|
15
15
|
* @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation.
|
|
16
16
|
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withRepeat
|
|
17
17
|
*/
|
|
18
|
-
export const withRepeat = function (_nextAnimation) {
|
|
18
|
+
export const withRepeat = function (_nextAnimation, numberOfReps = 2, reverse = false, callback, reduceMotion) {
|
|
19
19
|
'worklet';
|
|
20
20
|
|
|
21
|
-
let numberOfReps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
22
|
-
let reverse = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
23
|
-
let callback = arguments.length > 3 ? arguments[3] : undefined;
|
|
24
|
-
let reduceMotion = arguments.length > 4 ? arguments[4] : undefined;
|
|
25
21
|
return defineAnimation(_nextAnimation, () => {
|
|
26
22
|
'worklet';
|
|
27
23
|
|
|
@@ -58,7 +54,6 @@ export const withRepeat = function (_nextAnimation) {
|
|
|
58
54
|
nextAnimation.callback(false /* finished */);
|
|
59
55
|
}
|
|
60
56
|
};
|
|
61
|
-
|
|
62
57
|
function onStart(animation, value, now, previousAnimation) {
|
|
63
58
|
animation.startValue = value;
|
|
64
59
|
animation.reps = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withRepeat","_nextAnimation","numberOfReps","
|
|
1
|
+
{"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withRepeat","_nextAnimation","numberOfReps","reverse","callback","reduceMotion","nextAnimation","repeat","animation","now","finished","onFrame","current","reps","startValue","toValue","onStart","previousAnimation","repCallback","value","undefined","isHigherOrder"],"sources":["repeat.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type {\n Animation,\n AnimationCallback,\n AnimatableValue,\n Timestamp,\n AnimationObject,\n ReduceMotion,\n} from '../commonTypes';\nimport type { RepeatAnimation } from './commonTypes';\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withRepeatType = <T extends AnimatableValue>(\n animation: T,\n numberOfReps?: number,\n reverse?: boolean,\n callback?: AnimationCallback,\n reduceMotion?: ReduceMotion\n) => T;\n\n/**\n * Lets you repeat an animation given number of times or run it indefinitely.\n *\n * @param animation - An animation object you want to repeat.\n * @param numberOfReps - The number of times the animation is going to be repeated. Defaults to 2.\n * @param reverse - Whether the animation should run in reverse every other repetition. Defaults to false.\n * @param callback - A function called on animation complete.\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\n * @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withRepeat\n */\nexport const withRepeat = function <T extends AnimationObject>(\n _nextAnimation: T | (() => T),\n numberOfReps = 2,\n reverse = false,\n callback?: AnimationCallback,\n reduceMotion?: ReduceMotion\n): Animation<RepeatAnimation> {\n 'worklet';\n\n return defineAnimation<RepeatAnimation, T>(\n _nextAnimation,\n (): RepeatAnimation => {\n 'worklet';\n\n const nextAnimation =\n typeof _nextAnimation === 'function'\n ? _nextAnimation()\n : _nextAnimation;\n\n function repeat(animation: RepeatAnimation, 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 (\n animation.reduceMotion ||\n (numberOfReps > 0 && animation.reps >= numberOfReps)\n ) {\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: Animation<any> | null\n ): void {\n animation.startValue = value;\n animation.reps = 0;\n\n // child animations inherit the setting, unless they already have it defined\n // they will have it defined only if the user used the `reduceMotion` prop\n if (nextAnimation.reduceMotion === undefined) {\n nextAnimation.reduceMotion = animation.reduceMotion;\n }\n\n // don't start the animation if reduced motion is enabled and\n // the animation would end at its starting point\n if (\n animation.reduceMotion &&\n reverse &&\n (numberOfReps <= 0 || numberOfReps % 2 === 0)\n ) {\n animation.current = animation.startValue;\n animation.onFrame = () => true;\n } else {\n nextAnimation.onStart(nextAnimation, value, now, previousAnimation);\n }\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 reduceMotion: getReduceMotionForAnimation(reduceMotion),\n };\n }\n );\n} as withRepeatType;\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;;AAWrE;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAG,SAAAA,CACxBC,cAA6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AAa,CAACF,QAAQ,EAAE;QACvCE,aAAa,CAACF,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC;MAC9C;IACF,CAAC;IAED,SAASY,OAAOA,CACdR,SAA0B,EAC1BW,KAAsB,EACtBV,GAAc,EACdQ,iBAAwC,EAClC;MACNT,SAAS,CAACM,UAAU,GAAGK,KAAK;MAC5BX,SAAS,CAACK,IAAI,GAAG,CAAC;;MAElB;MACA;MACA,IAAIP,aAAa,CAACD,YAAY,KAAKe,SAAS,EAAE;QAC5Cd,aAAa,CAACD,YAAY,GAAGG,SAAS,CAACH,YAAY;MACrD;;MAEA;MACA;MACA,IACEG,SAAS,CAACH,YAAY,IACtBF,OAAO,KACND,YAAY,IAAI,CAAC,IAAIA,YAAY,GAAG,CAAC,KAAK,CAAC,CAAC,EAC7C;QACAM,SAAS,CAACI,OAAO,GAAGJ,SAAS,CAACM,UAAU;QACxCN,SAAS,CAACG,OAAO,GAAG,MAAM,IAAI;MAChC,CAAC,MAAM;QACLL,aAAa,CAACU,OAAO,CAACV,aAAa,EAAEa,KAAK,EAAEV,GAAG,EAAEQ,iBAAiB,CAAC;MACrE;IACF;IAEA,OAAO;MACLI,aAAa,EAAE,IAAI;MACnBV,OAAO,EAAEJ,MAAM;MACfS,OAAO;MACPH,IAAI,EAAE,CAAC;MACPD,OAAO,EAAEN,aAAa,CAACM,OAAO;MAC9BR,QAAQ,EAAEc,WAAW;MACrBJ,UAAU,EAAE,CAAC;MACbT,YAAY,EAAEN,2BAA2B,CAACM,YAAY;IACxD,CAAC;EACH,CACF,CAAC;AACH,CAAmB","ignoreList":[]}
|
|
@@ -11,12 +11,9 @@ import { defineAnimation, getReduceMotionForAnimation } from './util';
|
|
|
11
11
|
* @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSequence
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
export function withSequence(_reduceMotionOrFirstAnimation) {
|
|
14
|
+
export function withSequence(_reduceMotionOrFirstAnimation, ..._animations) {
|
|
15
15
|
'worklet';
|
|
16
16
|
|
|
17
|
-
for (var _len = arguments.length, _animations = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
18
|
-
_animations[_key - 1] = arguments[_key];
|
|
19
|
-
}
|
|
20
17
|
let reduceMotion;
|
|
21
18
|
|
|
22
19
|
// the first argument is either a config or an animation
|
|
@@ -80,7 +77,6 @@ export function withSequence(_reduceMotionOrFirstAnimation) {
|
|
|
80
77
|
if (currentAnim.callback) {
|
|
81
78
|
currentAnim.callback(true /* finished */);
|
|
82
79
|
}
|
|
83
|
-
|
|
84
80
|
currentAnim.finished = true;
|
|
85
81
|
animation.animationIndex = findNextNonReducedMotionAnimationIndex(animation.animationIndex + 1);
|
|
86
82
|
if (animation.animationIndex < animations.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withSequence","_reduceMotionOrFirstAnimation","
|
|
1
|
+
{"version":3,"names":["defineAnimation","getReduceMotionForAnimation","withSequence","_reduceMotionOrFirstAnimation","_animations","reduceMotion","unshift","length","console","warn","onStart","animation","value","current","onFrame","animationIndex","animations","map","a","result","finished","findNextNonReducedMotionAnimationIndex","index","callback","forEach","sequence","now","currentAnim","nextAnim","previousAnimation","anim","undefined","currentAnimation","isHigherOrder"],"sources":["sequence.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type { NextAnimation, SequenceAnimation } from './commonTypes';\nimport type {\n Animation,\n AnimatableValue,\n AnimationObject,\n ReduceMotion,\n Timestamp,\n} from '../commonTypes';\n\n/**\n * Lets you run animations in a sequence.\n *\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\n * @param animations - Any number of animation objects to be run in a sequence.\n * @returns An [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation/\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSequence\n */\nexport function withSequence<T extends AnimatableValue>(\n _reduceMotion: ReduceMotion,\n ...animations: T[]\n): T;\n\nexport function withSequence<T extends AnimatableValue>(...animations: T[]): T;\n\nexport function withSequence(\n _reduceMotionOrFirstAnimation?: ReduceMotion | NextAnimation<AnimationObject>,\n ..._animations: NextAnimation<AnimationObject>[]\n): Animation<SequenceAnimation> {\n 'worklet';\n let reduceMotion: ReduceMotion | undefined;\n\n // the first argument is either a config or an animation\n // this is done to allow the reduce motion config prop to be optional\n if (_reduceMotionOrFirstAnimation) {\n if (typeof _reduceMotionOrFirstAnimation === 'string') {\n reduceMotion = _reduceMotionOrFirstAnimation as ReduceMotion;\n } else {\n _animations.unshift(\n _reduceMotionOrFirstAnimation as NextAnimation<AnimationObject>\n );\n }\n }\n\n if (_animations.length === 0) {\n console.warn('[Reanimated] No animation was provided for the sequence');\n\n return defineAnimation<SequenceAnimation>(0, () => {\n 'worklet';\n return {\n onStart: (animation, value) => (animation.current = value),\n onFrame: () => true,\n current: 0,\n animationIndex: 0,\n reduceMotion: getReduceMotionForAnimation(reduceMotion),\n } as SequenceAnimation;\n });\n }\n\n return defineAnimation<SequenceAnimation>(\n _animations[0] as SequenceAnimation,\n () => {\n 'worklet';\n\n const animations = _animations.map((a) => {\n const result = typeof a === 'function' ? a() : a;\n result.finished = false;\n return result;\n });\n\n function findNextNonReducedMotionAnimationIndex(index: number) {\n // the last animation is returned even if reduced motion is enabled,\n // because we want the sequence to finish at the right spot\n while (\n index < animations.length - 1 &&\n animations[index].reduceMotion\n ) {\n index++;\n }\n\n return index;\n }\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 = findNextNonReducedMotionAnimationIndex(\n animation.animationIndex + 1\n );\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 // child animations inherit the setting, unless they already have it defined\n // they will have it defined only if the user used the `reduceMotion` prop\n animations.forEach((anim) => {\n if (anim.reduceMotion === undefined) {\n anim.reduceMotion = animation.reduceMotion;\n }\n });\n animation.animationIndex = findNextNonReducedMotionAnimationIndex(0);\n\n if (previousAnimation === undefined) {\n previousAnimation = animations[\n animations.length - 1\n ] as SequenceAnimation;\n }\n\n const currentAnimation = animations[animation.animationIndex];\n currentAnimation.onStart(\n currentAnimation,\n value,\n now,\n previousAnimation\n );\n }\n\n return {\n isHigherOrder: true,\n onFrame: sequence,\n onStart,\n animationIndex: 0,\n current: animations[0].current,\n callback,\n reduceMotion: getReduceMotionForAnimation(reduceMotion),\n } as SequenceAnimation;\n }\n );\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;;AAUrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA,OAAO,SAASC,YAAYA,CAC1BC,6BAA6E,EAC7E,GAAGC,WAA6C,EAClB;EAC9B,SAAS;;EACT,IAAIC,YAAsC;;EAE1C;EACA;EACA,IAAIF,6BAA6B,EAAE;IACjC,IAAI,OAAOA,6BAA6B,KAAK,QAAQ,EAAE;MACrDE,YAAY,GAAGF,6BAA6C;IAC9D,CAAC,MAAM;MACLC,WAAW,CAACE,OAAO,CACjBH,6BACF,CAAC;I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G,CAAC,CACD;MACxB;MAEA,MAAMyB,gBAAgB,GAAGhB,UAAU,CAACL,SAAS,CAACI,cAAc,CAAC;MAC7DiB,gBAAgB,CAACtB,OAAO,CACtBsB,gBAAgB,EAChBpB,KAAK,EACLc,GAAG,EACHG,iBACF,CAAC;IACH;IAEA,OAAO;MACLI,aAAa,EAAE,IAAI;MACnBnB,OAAO,EAAEW,QAAQ;MACjBf,OAAO;MACPK,cAAc,EAAE,CAAC;MACjBF,OAAO,EAAEG,UAAU,CAAC,CAAC,CAAC,CAACH,OAAO;MAC9BU,QAAQ;MACRlB,YAAY,EAAEJ,2BAA2B,CAACI,YAAY;IACxD,CAAC;EACH,CACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defineAnimation","getReduceMotionForAnimation","initialCalculations","calculateNewMassToMatchDuration","underDampedSpringCalculations","criticallyDampedSpringCalculations","isAnimationTerminatingCalculation","scaleZetaToMatchClamps","checkIfConfigIsValid","withSpring","toValue","userConfig","callback","defaultConfig","damping","mass","stiffness","overshootClamping","restDisplacementThreshold","restSpeedThreshold","velocity","duration","dampingRatio","reduceMotion","undefined","clamp","config","useDuration","skipAnimation","springOnFrame","animation","now","startTimestamp","current","timeFromStart","lastTimestamp","deltaTime","Math","min","t","v0","x0","zeta","omega0","omega1","position","newPosition","newVelocity","isOvershooting","isVelocity","isDisplacement","springIsNotInMove","isTriggeredTwice","previousAnimation","onStart","value","startValue","triggeredTwice","Number","actualDuration","onFrame"],"sources":["spring.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type {\n Animation,\n AnimationCallback,\n AnimatableValue,\n Timestamp,\n} from '../commonTypes';\nimport type {\n SpringConfig,\n SpringAnimation,\n InnerSpringAnimation,\n SpringConfigInner,\n DefaultSpringConfig,\n} from './springUtils';\nimport {\n initialCalculations,\n calculateNewMassToMatchDuration,\n underDampedSpringCalculations,\n criticallyDampedSpringCalculations,\n isAnimationTerminatingCalculation,\n scaleZetaToMatchClamps,\n checkIfConfigIsValid,\n} from './springUtils';\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withSpringType = <T extends AnimatableValue>(\n toValue: T,\n userConfig?: SpringConfig,\n callback?: AnimationCallback\n) => T;\n\n/**\n * Lets you create spring-based animations.\n *\n * @param toValue - the value at which the animation will come to rest - {@link AnimatableValue}\n * @param config - the spring animation configuration - {@link SpringConfig}\n * @param callback - a function called on animation complete - {@link AnimationCallback}\n * @returns an [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSpring\n */\nexport const withSpring = ((\n toValue: AnimatableValue,\n userConfig?: SpringConfig,\n callback?: AnimationCallback\n): Animation<SpringAnimation> => {\n 'worklet';\n\n return defineAnimation<SpringAnimation>(toValue, () => {\n 'worklet';\n const defaultConfig: DefaultSpringConfig = {\n damping: 10,\n mass: 1,\n stiffness: 100,\n overshootClamping: false,\n restDisplacementThreshold: 0.01,\n restSpeedThreshold: 2,\n velocity: 0,\n duration: 2000,\n dampingRatio: 0.5,\n reduceMotion: undefined,\n clamp: undefined,\n } as const;\n\n const config: DefaultSpringConfig & SpringConfigInner = {\n ...defaultConfig,\n ...userConfig,\n useDuration: !!(userConfig?.duration || userConfig?.dampingRatio),\n skipAnimation: false,\n };\n\n config.skipAnimation = !checkIfConfigIsValid(config);\n\n if (config.duration === 0) {\n config.skipAnimation = true;\n }\n\n function springOnFrame(\n animation: InnerSpringAnimation,\n now: Timestamp\n ): boolean {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { toValue, startTimestamp, current } = animation;\n\n const timeFromStart = now - startTimestamp;\n\n if (config.useDuration && timeFromStart >= config.duration) {\n animation.current = toValue;\n // clear lastTimestamp to avoid using stale value by the next spring animation that starts after this one\n animation.lastTimestamp = 0;\n return true;\n }\n\n if (config.skipAnimation) {\n animation.current = toValue;\n animation.lastTimestamp = 0;\n return true;\n }\n const { lastTimestamp, velocity } = animation;\n\n const deltaTime = Math.min(now - lastTimestamp, 64);\n animation.lastTimestamp = now;\n\n const t = deltaTime / 1000;\n const v0 = -velocity;\n const x0 = toValue - current;\n\n const { zeta, omega0, omega1 } = animation;\n\n const { position: newPosition, velocity: newVelocity } =\n zeta < 1\n ? underDampedSpringCalculations(animation, {\n zeta,\n v0,\n x0,\n omega0,\n omega1,\n t,\n })\n : criticallyDampedSpringCalculations(animation, {\n v0,\n x0,\n omega0,\n t,\n });\n\n animation.current = newPosition;\n animation.velocity = newVelocity;\n\n const { isOvershooting, isVelocity, isDisplacement } =\n isAnimationTerminatingCalculation(animation, config);\n\n const springIsNotInMove =\n isOvershooting || (isVelocity && isDisplacement);\n\n if (!config.useDuration && springIsNotInMove) {\n animation.velocity = 0;\n animation.current = toValue;\n // clear lastTimestamp to avoid using stale value by the next spring animation that starts after this one\n animation.lastTimestamp = 0;\n return true;\n }\n\n return false;\n }\n\n function isTriggeredTwice(\n previousAnimation: SpringAnimation | undefined,\n animation: SpringAnimation\n ) {\n return (\n previousAnimation?.lastTimestamp &&\n previousAnimation?.startTimestamp &&\n previousAnimation?.toValue === animation.toValue &&\n previousAnimation?.duration === animation.duration &&\n previousAnimation?.dampingRatio === animation.dampingRatio\n );\n }\n\n function onStart(\n animation: SpringAnimation,\n value: number,\n now: Timestamp,\n previousAnimation: SpringAnimation | undefined\n ): void {\n animation.current = value;\n animation.startValue = value;\n\n let mass = config.mass;\n const triggeredTwice = isTriggeredTwice(previousAnimation, animation);\n\n const duration = config.duration;\n\n const x0 = triggeredTwice\n ? // If animation is triggered twice we want to continue the previous animation\n // form the previous starting point\n previousAnimation?.startValue\n : Number(animation.toValue) - value;\n\n if (previousAnimation) {\n animation.velocity =\n (triggeredTwice\n ? previousAnimation?.velocity\n : previousAnimation?.velocity + config.velocity) || 0;\n } else {\n animation.velocity = config.velocity || 0;\n }\n\n if (triggeredTwice) {\n animation.zeta = previousAnimation?.zeta || 0;\n animation.omega0 = previousAnimation?.omega0 || 0;\n animation.omega1 = previousAnimation?.omega1 || 0;\n } else {\n if (config.useDuration) {\n const actualDuration = triggeredTwice\n ? // If animation is triggered twice we want to continue the previous animation\n // so we need to include the time that already elapsed\n duration -\n ((previousAnimation?.lastTimestamp || 0) -\n (previousAnimation?.startTimestamp || 0))\n : duration;\n\n config.duration = actualDuration;\n mass = calculateNewMassToMatchDuration(\n x0 as number,\n config,\n animation.velocity\n );\n }\n\n const { zeta, omega0, omega1 } = initialCalculations(mass, config);\n animation.zeta = zeta;\n animation.omega0 = omega0;\n animation.omega1 = omega1;\n\n if (config.clamp !== undefined) {\n animation.zeta = scaleZetaToMatchClamps(animation, config.clamp);\n }\n }\n\n animation.lastTimestamp = previousAnimation?.lastTimestamp || now;\n\n animation.startTimestamp = triggeredTwice\n ? previousAnimation?.startTimestamp || now\n : now;\n }\n\n return {\n onFrame: springOnFrame,\n onStart,\n toValue,\n velocity: config.velocity || 0,\n current: toValue,\n startValue: 0,\n callback,\n lastTimestamp: 0,\n startTimestamp: 0,\n zeta: 0,\n omega0: 0,\n omega1: 0,\n reduceMotion: getReduceMotionForAnimation(config.reduceMotion),\n } as SpringAnimation;\n });\n}) as withSpringType;\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;AAcrE,SACEC,mBAAmB,EACnBC,+BAA+B,EAC/BC,6BAA6B,EAC7BC,kCAAkC,EAClCC,iCAAiC,EACjCC,sBAAsB,EACtBC,oBAAoB,QACf,eAAe;;AAEtB;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAU,GAAIA,CACzBC,OAAwB,EACxBC,UAAyB,EACzBC,QAA4B,KACG;EAC/B,SAAS;;EAET,OAAOZ,eAAe,CAAkBU,OAAO,EAAE,MAAM;IACrD,SAAS;;IACT,MAAMG,aAAkC,GAAG;MACzCC,OAAO,EAA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,GAAG,CAAAkB,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAElB,aAAa,KAAIJ,GAAG;MAEjED,SAAS,CAACE,cAAc,GAAGyB,cAAc,GACrC,CAAAJ,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAErB,cAAc,KAAID,GAAG,GACxCA,GAAG;IACT;IAEA,OAAO;MACL6B,OAAO,EAAE/B,aAAa;MACtByB,OAAO;MACP5C,OAAO;MACPU,QAAQ,EAAEM,MAAM,CAACN,QAAQ,IAAI,CAAC;MAC9Ba,OAAO,EAAEvB,OAAO;MAChB8C,UAAU,EAAE,CAAC;MACb5C,QAAQ;MACRuB,aAAa,EAAE,CAAC;MAChBH,cAAc,EAAE,CAAC;MACjBU,IAAI,EAAE,CAAC;MACPC,MAAM,EAAE,CAAC;MACTC,MAAM,EAAE,CAAC;MACTrB,YAAY,EAAEtB,2BAA2B,CAACyB,MAAM,CAACH,YAAY;IAC/D,CAAC;EACH,CAAC,CAAC;AACJ,CAAoB"}
|
|
1
|
+
{"version":3,"names":["defineAnimation","getReduceMotionForAnimation","initialCalculations","calculateNewMassToMatchDuration","underDampedSpringCalculations","criticallyDampedSpringCalculations","isAnimationTerminatingCalculation","scaleZetaToMatchClamps","checkIfConfigIsValid","withSpring","toValue","userConfig","callback","defaultConfig","damping","mass","stiffness","overshootClamping","restDisplacementThreshold","restSpeedThreshold","velocity","duration","dampingRatio","reduceMotion","undefined","clamp","config","useDuration","skipAnimation","springOnFrame","animation","now","startTimestamp","current","timeFromStart","lastTimestamp","deltaTime","Math","min","t","v0","x0","zeta","omega0","omega1","position","newPosition","newVelocity","isOvershooting","isVelocity","isDisplacement","springIsNotInMove","isTriggeredTwice","previousAnimation","onStart","value","startValue","triggeredTwice","Number","actualDuration","onFrame"],"sources":["spring.ts"],"sourcesContent":["'use strict';\nimport { defineAnimation, getReduceMotionForAnimation } from './util';\nimport type {\n Animation,\n AnimationCallback,\n AnimatableValue,\n Timestamp,\n} from '../commonTypes';\nimport type {\n SpringConfig,\n SpringAnimation,\n InnerSpringAnimation,\n SpringConfigInner,\n DefaultSpringConfig,\n} from './springUtils';\nimport {\n initialCalculations,\n calculateNewMassToMatchDuration,\n underDampedSpringCalculations,\n criticallyDampedSpringCalculations,\n isAnimationTerminatingCalculation,\n scaleZetaToMatchClamps,\n checkIfConfigIsValid,\n} from './springUtils';\n\n// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.\ntype withSpringType = <T extends AnimatableValue>(\n toValue: T,\n userConfig?: SpringConfig,\n callback?: AnimationCallback\n) => T;\n\n/**\n * Lets you create spring-based animations.\n *\n * @param toValue - the value at which the animation will come to rest - {@link AnimatableValue}\n * @param config - the spring animation configuration - {@link SpringConfig}\n * @param callback - a function called on animation complete - {@link AnimationCallback}\n * @returns an [animation object](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animation-object) which holds the current state of the animation\n * @see https://docs.swmansion.com/react-native-reanimated/docs/animations/withSpring\n */\nexport const withSpring = ((\n toValue: AnimatableValue,\n userConfig?: SpringConfig,\n callback?: AnimationCallback\n): Animation<SpringAnimation> => {\n 'worklet';\n\n return defineAnimation<SpringAnimation>(toValue, () => {\n 'worklet';\n const defaultConfig: DefaultSpringConfig = {\n damping: 10,\n mass: 1,\n stiffness: 100,\n overshootClamping: false,\n restDisplacementThreshold: 0.01,\n restSpeedThreshold: 2,\n velocity: 0,\n duration: 2000,\n dampingRatio: 0.5,\n reduceMotion: undefined,\n clamp: undefined,\n } as const;\n\n const config: DefaultSpringConfig & SpringConfigInner = {\n ...defaultConfig,\n ...userConfig,\n useDuration: !!(userConfig?.duration || userConfig?.dampingRatio),\n skipAnimation: false,\n };\n\n config.skipAnimation = !checkIfConfigIsValid(config);\n\n if (config.duration === 0) {\n config.skipAnimation = true;\n }\n\n function springOnFrame(\n animation: InnerSpringAnimation,\n now: Timestamp\n ): boolean {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { toValue, startTimestamp, current } = animation;\n\n const timeFromStart = now - startTimestamp;\n\n if (config.useDuration && timeFromStart >= config.duration) {\n animation.current = toValue;\n // clear lastTimestamp to avoid using stale value by the next spring animation that starts after this one\n animation.lastTimestamp = 0;\n return true;\n }\n\n if (config.skipAnimation) {\n animation.current = toValue;\n animation.lastTimestamp = 0;\n return true;\n }\n const { lastTimestamp, velocity } = animation;\n\n const deltaTime = Math.min(now - lastTimestamp, 64);\n animation.lastTimestamp = now;\n\n const t = deltaTime / 1000;\n const v0 = -velocity;\n const x0 = toValue - current;\n\n const { zeta, omega0, omega1 } = animation;\n\n const { position: newPosition, velocity: newVelocity } =\n zeta < 1\n ? underDampedSpringCalculations(animation, {\n zeta,\n v0,\n x0,\n omega0,\n omega1,\n t,\n })\n : criticallyDampedSpringCalculations(animation, {\n v0,\n x0,\n omega0,\n t,\n });\n\n animation.current = newPosition;\n animation.velocity = newVelocity;\n\n const { isOvershooting, isVelocity, isDisplacement } =\n isAnimationTerminatingCalculation(animation, config);\n\n const springIsNotInMove =\n isOvershooting || (isVelocity && isDisplacement);\n\n if (!config.useDuration && springIsNotInMove) {\n animation.velocity = 0;\n animation.current = toValue;\n // clear lastTimestamp to avoid using stale value by the next spring animation that starts after this one\n animation.lastTimestamp = 0;\n return true;\n }\n\n return false;\n }\n\n function isTriggeredTwice(\n previousAnimation: SpringAnimation | undefined,\n animation: SpringAnimation\n ) {\n return (\n previousAnimation?.lastTimestamp &&\n previousAnimation?.startTimestamp &&\n previousAnimation?.toValue === animation.toValue &&\n previousAnimation?.duration === animation.duration &&\n previousAnimation?.dampingRatio === animation.dampingRatio\n );\n }\n\n function onStart(\n animation: SpringAnimation,\n value: number,\n now: Timestamp,\n previousAnimation: SpringAnimation | undefined\n ): void {\n animation.current = value;\n animation.startValue = value;\n\n let mass = config.mass;\n const triggeredTwice = isTriggeredTwice(previousAnimation, animation);\n\n const duration = config.duration;\n\n const x0 = triggeredTwice\n ? // If animation is triggered twice we want to continue the previous animation\n // form the previous starting point\n previousAnimation?.startValue\n : Number(animation.toValue) - value;\n\n if (previousAnimation) {\n animation.velocity =\n (triggeredTwice\n ? previousAnimation?.velocity\n : previousAnimation?.velocity + config.velocity) || 0;\n } else {\n animation.velocity = config.velocity || 0;\n }\n\n if (triggeredTwice) {\n animation.zeta = previousAnimation?.zeta || 0;\n animation.omega0 = previousAnimation?.omega0 || 0;\n animation.omega1 = previousAnimation?.omega1 || 0;\n } else {\n if (config.useDuration) {\n const actualDuration = triggeredTwice\n ? // If animation is triggered twice we want to continue the previous animation\n // so we need to include the time that already elapsed\n duration -\n ((previousAnimation?.lastTimestamp || 0) -\n (previousAnimation?.startTimestamp || 0))\n : duration;\n\n config.duration = actualDuration;\n mass = calculateNewMassToMatchDuration(\n x0 as number,\n config,\n animation.velocity\n );\n }\n\n const { zeta, omega0, omega1 } = initialCalculations(mass, config);\n animation.zeta = zeta;\n animation.omega0 = omega0;\n animation.omega1 = omega1;\n\n if (config.clamp !== undefined) {\n animation.zeta = scaleZetaToMatchClamps(animation, config.clamp);\n }\n }\n\n animation.lastTimestamp = previousAnimation?.lastTimestamp || now;\n\n animation.startTimestamp = triggeredTwice\n ? previousAnimation?.startTimestamp || now\n : now;\n }\n\n return {\n onFrame: springOnFrame,\n onStart,\n toValue,\n velocity: config.velocity || 0,\n current: toValue,\n startValue: 0,\n callback,\n lastTimestamp: 0,\n startTimestamp: 0,\n zeta: 0,\n omega0: 0,\n omega1: 0,\n reduceMotion: getReduceMotionForAnimation(config.reduceMotion),\n } as SpringAnimation;\n });\n}) as withSpringType;\n"],"mappings":"AAAA,YAAY;;AACZ,SAASA,eAAe,EAAEC,2BAA2B,QAAQ,QAAQ;AAcrE,SACEC,mBAAmB,EACnBC,+BAA+B,EAC/BC,6BAA6B,EAC7BC,kCAAkC,EAClCC,iCAAiC,EACjCC,sBAAsB,EACtBC,oBAAoB,QACf,eAAe;;AAEtB;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UA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