react-native-reanimated 3.6.0 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js +12 -0
- package/lib/module/createAnimatedComponent/createAnimatedComponent.js.map +1 -1
- package/lib/module/createAnimatedComponent/setAndForwardRef.js +2 -0
- package/lib/module/createAnimatedComponent/setAndForwardRef.js.map +1 -1
- package/lib/module/reanimated2/Easing.js +3 -3
- package/lib/module/reanimated2/Easing.js.map +1 -1
- package/lib/module/reanimated2/PlatformChecker.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/decay.js +9 -0
- package/lib/module/reanimated2/animation/decay/decay.js.map +1 -1
- package/lib/module/reanimated2/animation/decay/utils.js +13 -0
- package/lib/module/reanimated2/animation/decay/utils.js.map +1 -1
- package/lib/module/reanimated2/animation/delay.js +9 -0
- package/lib/module/reanimated2/animation/delay.js.map +1 -1
- package/lib/module/reanimated2/animation/repeat.js +11 -0
- package/lib/module/reanimated2/animation/repeat.js.map +1 -1
- package/lib/module/reanimated2/animation/sequence.js +10 -0
- package/lib/module/reanimated2/animation/sequence.js.map +1 -1
- package/lib/module/reanimated2/animation/spring.js +9 -0
- package/lib/module/reanimated2/animation/spring.js.map +1 -1
- package/lib/module/reanimated2/animation/springUtils.js +16 -0
- package/lib/module/reanimated2/animation/springUtils.js.map +1 -1
- package/lib/module/reanimated2/animation/timing.js +18 -0
- package/lib/module/reanimated2/animation/timing.js.map +1 -1
- package/lib/module/reanimated2/animation/util.js +7 -0
- package/lib/module/reanimated2/animation/util.js.map +1 -1
- package/lib/module/reanimated2/commonTypes.js +30 -7
- package/lib/module/reanimated2/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/component/FlatList.js.map +1 -1
- package/lib/module/reanimated2/component/LayoutAnimationConfig.js +7 -0
- package/lib/module/reanimated2/component/LayoutAnimationConfig.js.map +1 -1
- package/lib/module/reanimated2/component/ScrollView.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/useAnimatedKeyboard.js +8 -0
- package/lib/module/reanimated2/hook/useAnimatedKeyboard.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedProps.js +9 -0
- package/lib/module/reanimated2/hook/useAnimatedProps.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedReaction.js +6 -4
- package/lib/module/reanimated2/hook/useAnimatedReaction.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedRef.js +7 -0
- package/lib/module/reanimated2/hook/useAnimatedRef.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js +10 -2
- package/lib/module/reanimated2/hook/useAnimatedScrollHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedSensor.js +10 -0
- package/lib/module/reanimated2/hook/useAnimatedSensor.js.map +1 -1
- package/lib/module/reanimated2/hook/useAnimatedStyle.js +8 -0
- package/lib/module/reanimated2/hook/useAnimatedStyle.js.map +1 -1
- package/lib/module/reanimated2/hook/useDerivedValue.js +14 -8
- package/lib/module/reanimated2/hook/useDerivedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useEvent.js +7 -6
- package/lib/module/reanimated2/hook/useEvent.js.map +1 -1
- package/lib/module/reanimated2/hook/useFrameCallback.js +17 -0
- package/lib/module/reanimated2/hook/useFrameCallback.js.map +1 -1
- package/lib/module/reanimated2/hook/useHandler.js +8 -2
- package/lib/module/reanimated2/hook/useHandler.js.map +1 -1
- package/lib/module/reanimated2/hook/useReducedMotion.js +9 -0
- package/lib/module/reanimated2/hook/useReducedMotion.js.map +1 -1
- package/lib/module/reanimated2/hook/useScrollViewOffset.js +8 -0
- package/lib/module/reanimated2/hook/useScrollViewOffset.js.map +1 -1
- package/lib/module/reanimated2/hook/useSharedValue.js +11 -3
- package/lib/module/reanimated2/hook/useSharedValue.js.map +1 -1
- package/lib/module/reanimated2/hook/useWorkletCallback.js +3 -0
- package/lib/module/reanimated2/hook/useWorkletCallback.js.map +1 -1
- package/lib/module/reanimated2/index.js +1 -1
- package/lib/module/reanimated2/index.js.map +1 -1
- package/lib/module/reanimated2/interpolateColor.js +21 -0
- package/lib/module/reanimated2/interpolateColor.js.map +1 -1
- package/lib/module/reanimated2/interpolation.js +51 -21
- package/lib/module/reanimated2/interpolation.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js +29 -2
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js +67 -2
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js +6 -3
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/Keyframe.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js +4 -0
- package/lib/module/reanimated2/layoutReanimation/animationBuilder/commonTypes.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js +80 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Bounce.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js +79 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Fade.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js +96 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Flip.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js +31 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js +15 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js +31 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Roll.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js +63 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Rotate.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js +64 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Slide.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js +32 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Stretch.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js +128 -0
- package/lib/module/reanimated2/layoutReanimation/defaultAnimations/Zoom.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js +8 -0
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js +9 -0
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js +8 -0
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js +8 -0
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js +10 -3
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js +8 -0
- package/lib/module/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js +49 -3
- package/lib/module/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.js.map +1 -1
- package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js +4 -4
- package/lib/module/reanimated2/layoutReanimation/web/createAnimation.js.map +1 -1
- package/lib/module/reanimated2/platform-specific/checkCppVersion.js +0 -2
- 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 +9 -0
- package/lib/module/reanimated2/platformFunctions/dispatchCommand.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js +14 -4
- package/lib/module/reanimated2/platformFunctions/getRelativeCoords.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/measure.js +7 -0
- package/lib/module/reanimated2/platformFunctions/measure.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/scrollTo.js +9 -0
- package/lib/module/reanimated2/platformFunctions/scrollTo.js.map +1 -1
- package/lib/module/reanimated2/platformFunctions/setNativeProps.js +8 -0
- package/lib/module/reanimated2/platformFunctions/setNativeProps.js.map +1 -1
- package/lib/module/reanimated2/runtimes.js +8 -0
- package/lib/module/reanimated2/runtimes.js.map +1 -1
- package/lib/module/reanimated2/threads.js +16 -6
- package/lib/module/reanimated2/threads.js.map +1 -1
- package/lib/typescript/createAnimatedComponent/createAnimatedComponent.d.ts +12 -0
- package/lib/typescript/reanimated2/Easing.d.ts +3 -3
- package/lib/typescript/reanimated2/animation/decay/decay.d.ts +8 -0
- package/lib/typescript/reanimated2/animation/decay/utils.d.ts +12 -0
- package/lib/typescript/reanimated2/animation/delay.d.ts +9 -0
- package/lib/typescript/reanimated2/animation/repeat.d.ts +11 -0
- package/lib/typescript/reanimated2/animation/sequence.d.ts +8 -0
- package/lib/typescript/reanimated2/animation/spring.d.ts +9 -0
- package/lib/typescript/reanimated2/animation/springUtils.d.ts +15 -0
- package/lib/typescript/reanimated2/animation/timing.d.ts +17 -0
- package/lib/typescript/reanimated2/animation/util.d.ts +6 -0
- package/lib/typescript/reanimated2/commonTypes.d.ts +25 -7
- package/lib/typescript/reanimated2/component/FlatList.d.ts +6 -0
- package/lib/typescript/reanimated2/component/LayoutAnimationConfig.d.ts +7 -0
- package/lib/typescript/reanimated2/component/ScrollView.d.ts +3 -2
- package/lib/typescript/reanimated2/helperTypes.d.ts +45 -3
- package/lib/typescript/reanimated2/hook/useAnimatedKeyboard.d.ts +7 -0
- package/lib/typescript/reanimated2/hook/useAnimatedProps.d.ts +9 -0
- package/lib/typescript/reanimated2/hook/useAnimatedReaction.d.ts +6 -4
- package/lib/typescript/reanimated2/hook/useAnimatedRef.d.ts +6 -0
- package/lib/typescript/reanimated2/hook/useAnimatedScrollHandler.d.ts +10 -0
- package/lib/typescript/reanimated2/hook/useAnimatedSensor.d.ts +8 -0
- package/lib/typescript/reanimated2/hook/useAnimatedStyle.d.ts +8 -0
- package/lib/typescript/reanimated2/hook/useDerivedValue.d.ts +9 -1
- package/lib/typescript/reanimated2/hook/useEvent.d.ts +8 -5
- package/lib/typescript/reanimated2/hook/useFrameCallback.d.ts +14 -0
- package/lib/typescript/reanimated2/hook/useHandler.d.ts +8 -0
- package/lib/typescript/reanimated2/hook/useReducedMotion.d.ts +8 -0
- package/lib/typescript/reanimated2/hook/useScrollViewOffset.d.ts +7 -0
- package/lib/typescript/reanimated2/hook/useSharedValue.d.ts +8 -1
- package/lib/typescript/reanimated2/hook/useWorkletCallback.d.ts +3 -0
- package/lib/typescript/reanimated2/index.d.ts +1 -1
- package/lib/typescript/reanimated2/interpolateColor.d.ts +17 -0
- package/lib/typescript/reanimated2/interpolation.d.ts +30 -2
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.d.ts +25 -2
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.d.ts +56 -1
- package/lib/typescript/reanimated2/layoutReanimation/animationBuilder/commonTypes.d.ts +4 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Bounce.d.ts +70 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Fade.d.ts +70 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Flip.d.ts +84 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.d.ts +28 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.d.ts +14 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Roll.d.ts +28 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Rotate.d.ts +56 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Slide.d.ts +56 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Stretch.d.ts +28 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultAnimations/Zoom.d.ts +112 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.d.ts +7 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.d.ts +8 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.d.ts +7 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.d.ts +7 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.d.ts +10 -0
- package/lib/typescript/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.d.ts +7 -0
- package/lib/typescript/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.d.ts +43 -1
- package/lib/typescript/reanimated2/layoutReanimation/web/createAnimation.d.ts +4 -4
- package/lib/typescript/reanimated2/platform-specific/jsVersion.d.ts +1 -1
- package/lib/typescript/reanimated2/platformFunctions/dispatchCommand.d.ts +8 -0
- package/lib/typescript/reanimated2/platformFunctions/getRelativeCoords.d.ts +11 -3
- package/lib/typescript/reanimated2/platformFunctions/measure.d.ts +7 -0
- package/lib/typescript/reanimated2/platformFunctions/scrollTo.d.ts +9 -0
- package/lib/typescript/reanimated2/platformFunctions/setNativeProps.d.ts +7 -0
- package/lib/typescript/reanimated2/runtimes.d.ts +8 -0
- package/lib/typescript/reanimated2/threads.d.ts +17 -2
- package/package.json +2 -1
- package/src/createAnimatedComponent/createAnimatedComponent.tsx +18 -0
- package/src/createAnimatedComponent/setAndForwardRef.ts +2 -0
- package/src/reanimated2/Easing.ts +3 -3
- package/src/reanimated2/PlatformChecker.ts +1 -1
- package/src/reanimated2/animation/decay/decay.ts +8 -0
- package/src/reanimated2/animation/decay/utils.ts +12 -0
- package/src/reanimated2/animation/delay.ts +9 -0
- package/src/reanimated2/animation/repeat.ts +11 -0
- package/src/reanimated2/animation/sequence.ts +8 -0
- package/src/reanimated2/animation/spring.ts +9 -0
- package/src/reanimated2/animation/springUtils.ts +15 -0
- package/src/reanimated2/animation/timing.ts +17 -0
- package/src/reanimated2/animation/util.ts +6 -0
- package/src/reanimated2/commonTypes.ts +25 -7
- package/src/reanimated2/component/FlatList.tsx +6 -0
- package/src/reanimated2/component/LayoutAnimationConfig.tsx +7 -0
- package/src/reanimated2/component/ScrollView.tsx +3 -1
- package/src/reanimated2/globals.d.ts +1 -1
- package/src/reanimated2/helperTypes.ts +45 -3
- package/src/reanimated2/hook/useAnimatedKeyboard.ts +7 -0
- package/src/reanimated2/hook/useAnimatedProps.ts +9 -0
- package/src/reanimated2/hook/useAnimatedReaction.ts +6 -4
- package/src/reanimated2/hook/useAnimatedRef.ts +6 -0
- package/src/reanimated2/hook/useAnimatedScrollHandler.ts +10 -0
- package/src/reanimated2/hook/useAnimatedSensor.ts +8 -0
- package/src/reanimated2/hook/useAnimatedStyle.ts +8 -0
- package/src/reanimated2/hook/useDerivedValue.ts +15 -7
- package/src/reanimated2/hook/useEvent.ts +9 -6
- package/src/reanimated2/hook/useFrameCallback.ts +14 -0
- package/src/reanimated2/hook/useHandler.ts +8 -0
- package/src/reanimated2/hook/useReducedMotion.ts +8 -0
- package/src/reanimated2/hook/useScrollViewOffset.ts +7 -0
- package/src/reanimated2/hook/useSharedValue.ts +12 -3
- package/src/reanimated2/hook/useWorkletCallback.ts +3 -0
- package/src/reanimated2/index.ts +1 -1
- package/src/reanimated2/interpolateColor.ts +17 -0
- package/src/reanimated2/interpolation.ts +48 -22
- package/src/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.ts +26 -3
- package/src/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.ts +57 -2
- package/src/reanimated2/layoutReanimation/animationBuilder/Keyframe.ts +7 -6
- package/src/reanimated2/layoutReanimation/animationBuilder/commonTypes.ts +4 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Bounce.ts +71 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Fade.ts +70 -1
- package/src/reanimated2/layoutReanimation/defaultAnimations/Flip.ts +84 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Lightspeed.ts +28 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Pinwheel.ts +14 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Roll.ts +28 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Rotate.ts +56 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Slide.ts +56 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Stretch.ts +28 -0
- package/src/reanimated2/layoutReanimation/defaultAnimations/Zoom.ts +112 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/CurvedTransition.ts +7 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/EntryExitTransition.ts +8 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/FadingTransition.ts +7 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/JumpingTransition.ts +8 -0
- package/src/reanimated2/layoutReanimation/defaultTransitions/LinearTransition.ts +10 -3
- package/src/reanimated2/layoutReanimation/defaultTransitions/SequencedTransition.ts +7 -0
- package/src/reanimated2/layoutReanimation/sharedTransitions/SharedTransition.ts +45 -3
- package/src/reanimated2/layoutReanimation/web/createAnimation.ts +4 -4
- package/src/reanimated2/platform-specific/checkCppVersion.ts +0 -4
- package/src/reanimated2/platform-specific/jsVersion.ts +1 -1
- package/src/reanimated2/platformFunctions/dispatchCommand.ts +8 -0
- package/src/reanimated2/platformFunctions/getRelativeCoords.ts +12 -4
- package/src/reanimated2/platformFunctions/measure.ts +7 -0
- package/src/reanimated2/platformFunctions/scrollTo.ts +9 -0
- package/src/reanimated2/platformFunctions/setNativeProps.ts +7 -0
- package/src/reanimated2/runtimes.ts +8 -0
- package/src/reanimated2/threads.ts +18 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hsvToColor","RGBtoHSV","rgbaColor","processColor","red","green","blue","opacity","makeMutable","Extrapolation","interpolate","useSharedValue","Extrapolate","interpolateColorsHSV","value","inputRange","colors","options","h","useCorrectedHSVInterpolation","correctedInputRange","originalH","correctedH","i","length","d","push","CLAMP","s","v","a","toLinearSpace","x","gamma","map","Math","pow","toGammaSpace","round","interpolateColorsRGB","r","outputR","g","outputG","b","outputB","getInterpolateRGB","color","processedColor","undefined","getInterpolateHSV","processedHSVColor","interpolateColor","outputRange","colorSpace","arguments","Error","ColorSpace","useInterpolateConfig","RGB","cache"],"sources":["interpolateColor.ts"],"sourcesContent":["'use strict';\nimport {\n hsvToColor,\n RGBtoHSV,\n rgbaColor,\n processColor,\n red,\n green,\n blue,\n opacity,\n} from './Colors';\nimport { makeMutable } from './core';\nimport { Extrapolation, interpolate } from './interpolation';\nimport type { SharedValue } from './commonTypes';\nimport { useSharedValue } from './hook/useSharedValue';\n\n/**\n * @deprecated Please use Extrapolation instead\n */\nexport const Extrapolate = Extrapolation;\n\nexport type InterpolationOptions = {\n gamma?: number;\n useCorrectedHSVInterpolation?: boolean;\n};\n\nconst interpolateColorsHSV = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateHSV,\n options: InterpolationOptions\n) => {\n 'worklet';\n let h = 0;\n const { useCorrectedHSVInterpolation = true } = options;\n if (useCorrectedHSVInterpolation) {\n // if the difference between hues in a range is > 180 deg\n // then move the hue at the right end of the range +/- 360 deg\n // and add the next point in the original place + 0.00001 with original hue\n // to not break the next range\n const correctedInputRange = [inputRange[0]];\n const originalH = colors.h;\n const correctedH = [originalH[0]];\n\n for (let i = 1; i < originalH.length; ++i) {\n const d = originalH[i] - originalH[i - 1];\n if (originalH[i] > originalH[i - 1] && d > 0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] - 1);\n correctedH.push(originalH[i]);\n } else if (originalH[i] < originalH[i - 1] && d < -0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] + 1);\n correctedH.push(originalH[i]);\n } else {\n correctedInputRange.push(inputRange[i]);\n correctedH.push(originalH[i]);\n }\n }\n h =\n (interpolate(\n value,\n correctedInputRange,\n correctedH,\n Extrapolation.CLAMP\n ) +\n 1) %\n 1;\n } else {\n h = interpolate(value, inputRange, colors.h, Extrapolation.CLAMP);\n }\n const s = interpolate(value, inputRange, colors.s, Extrapolation.CLAMP);\n const v = interpolate(value, inputRange, colors.v, Extrapolation.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolation.CLAMP);\n return hsvToColor(h, s, v, a);\n};\n\nconst toLinearSpace = (x: number[], gamma: number): number[] => {\n 'worklet';\n return x.map((v) => Math.pow(v / 255, gamma));\n};\n\nconst toGammaSpace = (x: number, gamma: number): number => {\n 'worklet';\n return Math.round(Math.pow(x, 1 / gamma) * 255);\n};\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateRGB,\n options: InterpolationOptions\n) => {\n 'worklet';\n const { gamma = 2.2 } = options;\n let { r: outputR, g: outputG, b: outputB } = colors;\n if (gamma !== 1) {\n outputR = toLinearSpace(outputR, gamma);\n outputG = toLinearSpace(outputG, gamma);\n outputB = toLinearSpace(outputB, gamma);\n }\n const r = interpolate(value, inputRange, outputR, Extrapolation.CLAMP);\n const g = interpolate(value, inputRange, outputG, Extrapolation.CLAMP);\n const b = interpolate(value, inputRange, outputB, Extrapolation.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolation.CLAMP);\n if (gamma === 1) {\n return rgbaColor(r, g, b, a);\n }\n return rgbaColor(\n toGammaSpace(r, gamma),\n toGammaSpace(g, gamma),\n toGammaSpace(b, gamma),\n a\n );\n};\n\nexport interface InterpolateRGB {\n r: number[];\n g: number[];\n b: number[];\n a: number[];\n}\n\nconst getInterpolateRGB = (\n colors: readonly (string | number)[]\n): InterpolateRGB => {\n 'worklet';\n\n const r = [];\n const g = [];\n const b = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color);\n // explicit check in case if processedColor is 0\n if (processedColor !== null && processedColor !== undefined) {\n r.push(red(processedColor));\n g.push(green(processedColor));\n b.push(blue(processedColor));\n a.push(opacity(processedColor));\n }\n }\n return { r, g, b, a };\n};\n\nexport interface InterpolateHSV {\n h: number[];\n s: number[];\n v: number[];\n a: number[];\n}\n\nconst getInterpolateHSV = (\n colors: readonly (string | number)[]\n): InterpolateHSV => {\n 'worklet';\n const h = [];\n const s = [];\n const v = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color) as any;\n if (typeof processedColor === 'number') {\n const processedHSVColor = RGBtoHSV(\n red(processedColor),\n green(processedColor),\n blue(processedColor)\n );\n\n h.push(processedHSVColor.h);\n s.push(processedHSVColor.s);\n v.push(processedHSVColor.v);\n a.push(opacity(processedColor));\n }\n }\n return { h, s, v, a };\n};\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly string[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): string;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): number;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace: 'RGB' | 'HSV' = 'RGB',\n options: InterpolationOptions = {}\n): string | number {\n 'worklet';\n if (colorSpace === 'HSV') {\n return interpolateColorsHSV(\n value,\n inputRange,\n getInterpolateHSV(outputRange),\n options\n );\n } else if (colorSpace === 'RGB') {\n return interpolateColorsRGB(\n value,\n inputRange,\n getInterpolateRGB(outputRange),\n options\n );\n }\n throw new Error(\n `[Reanimated] Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV'].`\n );\n}\n\nexport enum ColorSpace {\n RGB = 0,\n HSV = 1,\n}\n\nexport interface InterpolateConfig {\n inputRange: readonly number[];\n outputRange: readonly (string | number)[];\n colorSpace: ColorSpace;\n cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;\n options: InterpolationOptions;\n}\n\nexport function useInterpolateConfig(\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace = ColorSpace.RGB,\n options: InterpolationOptions = {}\n): SharedValue<InterpolateConfig> {\n return useSharedValue<InterpolateConfig>({\n inputRange,\n outputRange,\n colorSpace,\n cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),\n options,\n });\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SACEA,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,YAAY,EACZC,GAAG,EACHC,KAAK,EACLC,IAAI,EACJC,OAAO,QACF,UAAU;AACjB,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,aAAa,EAAEC,WAAW,QAAQ,iBAAiB;AAE5D,SAASC,cAAc,QAAQ,uBAAuB;;AAEtD;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAGH,aAAa;AAOxC,MAAMI,oBAAoB,GAAGA,CAC3BC,KAAa,EACbC,UAA6B,EAC7BC,MAAsB,EACtBC,OAA6B,KAC1B;EACH,SAA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KAAK,CACZ,8CAA6CF,UAAW,yCAAwC,CAClG;AACH;AAEA,WAAYG,UAAU,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;AAatB,OAAO,SAASC,oBAAoBA,CAClC3C,UAA6B,EAC7BsC,WAAyC,EAGT;EAAA,IAFhCC,UAAU,GAAAC,SAAA,CAAA/B,MAAA,QAAA+B,SAAA,QAAAN,SAAA,GAAAM,SAAA,MAAGE,UAAU,CAACE,GAAG;EAAA,IAC3B1C,OAA6B,GAAAsC,SAAA,CAAA/B,MAAA,QAAA+B,SAAA,QAAAN,SAAA,GAAAM,SAAA,MAAG,CAAC,CAAC;EAElC,OAAO5C,cAAc,CAAoB;IACvCI,UAAU;IACVsC,WAAW;IACXC,UAAU;IACVM,KAAK,EAAEpD,WAAW,CAAyC,IAAI,CAAC;IAChES;EACF,CAAC,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"names":["hsvToColor","RGBtoHSV","rgbaColor","processColor","red","green","blue","opacity","makeMutable","Extrapolation","interpolate","useSharedValue","Extrapolate","interpolateColorsHSV","value","inputRange","colors","options","h","useCorrectedHSVInterpolation","correctedInputRange","originalH","correctedH","i","length","d","push","CLAMP","s","v","a","toLinearSpace","x","gamma","map","Math","pow","toGammaSpace","round","interpolateColorsRGB","r","outputR","g","outputG","b","outputB","getInterpolateRGB","color","processedColor","undefined","getInterpolateHSV","processedHSVColor","interpolateColor","outputRange","colorSpace","arguments","Error","ColorSpace","useInterpolateConfig","RGB","cache"],"sources":["interpolateColor.ts"],"sourcesContent":["'use strict';\nimport {\n hsvToColor,\n RGBtoHSV,\n rgbaColor,\n processColor,\n red,\n green,\n blue,\n opacity,\n} from './Colors';\nimport { makeMutable } from './core';\nimport { Extrapolation, interpolate } from './interpolation';\nimport type { SharedValue } from './commonTypes';\nimport { useSharedValue } from './hook/useSharedValue';\n\n/**\n * @deprecated Please use Extrapolation instead\n */\nexport const Extrapolate = Extrapolation;\n\n/**\n * Options for color interpolation.\n *\n * @param gamma - Gamma value used in gamma correction. Defaults to `2.2`.\n * @param useCorrectedHSVInterpolation - Whether to reduce the number of colors the interpolation has to go through. Defaults to `true`.\n */\nexport type InterpolationOptions = {\n gamma?: number;\n useCorrectedHSVInterpolation?: boolean;\n};\n\nconst interpolateColorsHSV = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateHSV,\n options: InterpolationOptions\n) => {\n 'worklet';\n let h = 0;\n const { useCorrectedHSVInterpolation = true } = options;\n if (useCorrectedHSVInterpolation) {\n // if the difference between hues in a range is > 180 deg\n // then move the hue at the right end of the range +/- 360 deg\n // and add the next point in the original place + 0.00001 with original hue\n // to not break the next range\n const correctedInputRange = [inputRange[0]];\n const originalH = colors.h;\n const correctedH = [originalH[0]];\n\n for (let i = 1; i < originalH.length; ++i) {\n const d = originalH[i] - originalH[i - 1];\n if (originalH[i] > originalH[i - 1] && d > 0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] - 1);\n correctedH.push(originalH[i]);\n } else if (originalH[i] < originalH[i - 1] && d < -0.5) {\n correctedInputRange.push(inputRange[i]);\n correctedInputRange.push(inputRange[i] + 0.00001);\n correctedH.push(originalH[i] + 1);\n correctedH.push(originalH[i]);\n } else {\n correctedInputRange.push(inputRange[i]);\n correctedH.push(originalH[i]);\n }\n }\n h =\n (interpolate(\n value,\n correctedInputRange,\n correctedH,\n Extrapolation.CLAMP\n ) +\n 1) %\n 1;\n } else {\n h = interpolate(value, inputRange, colors.h, Extrapolation.CLAMP);\n }\n const s = interpolate(value, inputRange, colors.s, Extrapolation.CLAMP);\n const v = interpolate(value, inputRange, colors.v, Extrapolation.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolation.CLAMP);\n return hsvToColor(h, s, v, a);\n};\n\nconst toLinearSpace = (x: number[], gamma: number): number[] => {\n 'worklet';\n return x.map((v) => Math.pow(v / 255, gamma));\n};\n\nconst toGammaSpace = (x: number, gamma: number): number => {\n 'worklet';\n return Math.round(Math.pow(x, 1 / gamma) * 255);\n};\n\nconst interpolateColorsRGB = (\n value: number,\n inputRange: readonly number[],\n colors: InterpolateRGB,\n options: InterpolationOptions\n) => {\n 'worklet';\n const { gamma = 2.2 } = options;\n let { r: outputR, g: outputG, b: outputB } = colors;\n if (gamma !== 1) {\n outputR = toLinearSpace(outputR, gamma);\n outputG = toLinearSpace(outputG, gamma);\n outputB = toLinearSpace(outputB, gamma);\n }\n const r = interpolate(value, inputRange, outputR, Extrapolation.CLAMP);\n const g = interpolate(value, inputRange, outputG, Extrapolation.CLAMP);\n const b = interpolate(value, inputRange, outputB, Extrapolation.CLAMP);\n const a = interpolate(value, inputRange, colors.a, Extrapolation.CLAMP);\n if (gamma === 1) {\n return rgbaColor(r, g, b, a);\n }\n return rgbaColor(\n toGammaSpace(r, gamma),\n toGammaSpace(g, gamma),\n toGammaSpace(b, gamma),\n a\n );\n};\n\nexport interface InterpolateRGB {\n r: number[];\n g: number[];\n b: number[];\n a: number[];\n}\n\nconst getInterpolateRGB = (\n colors: readonly (string | number)[]\n): InterpolateRGB => {\n 'worklet';\n\n const r = [];\n const g = [];\n const b = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color);\n // explicit check in case if processedColor is 0\n if (processedColor !== null && processedColor !== undefined) {\n r.push(red(processedColor));\n g.push(green(processedColor));\n b.push(blue(processedColor));\n a.push(opacity(processedColor));\n }\n }\n return { r, g, b, a };\n};\n\nexport interface InterpolateHSV {\n h: number[];\n s: number[];\n v: number[];\n a: number[];\n}\n\nconst getInterpolateHSV = (\n colors: readonly (string | number)[]\n): InterpolateHSV => {\n 'worklet';\n const h = [];\n const s = [];\n const v = [];\n const a = [];\n for (let i = 0; i < colors.length; ++i) {\n const color = colors[i];\n const processedColor = processColor(color) as any;\n if (typeof processedColor === 'number') {\n const processedHSVColor = RGBtoHSV(\n red(processedColor),\n green(processedColor),\n blue(processedColor)\n );\n\n h.push(processedHSVColor.h);\n s.push(processedHSVColor.s);\n v.push(processedHSVColor.v);\n a.push(opacity(processedColor));\n }\n }\n return { h, s, v, a };\n};\n\n/**\n * Lets you map a value from a range of numbers to a range of colors using linear interpolation.\n *\n * @param value - A number from the `input` range that is going to be mapped to the color in the `output` range.\n * @param inputRange - An array of numbers specifying the input range of the interpolation.\n * @param outputRange - An array of output colors values (eg. \"red\", \"#00FFCC\", \"rgba(255, 0, 0, 0.5)\").\n * @param colorSpace - The color space to use for interpolation. Defaults to 'RGB'.\n * @param options - Additional options for interpolation - {@link InterpolationOptions}.\n * @returns The color after interpolation from within the output range in rgba(r, g, b, a) format.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/interpolateColor\n */\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly string[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): string;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n colorSpace?: 'RGB' | 'HSV',\n options?: InterpolationOptions\n): number;\n\nexport function interpolateColor(\n value: number,\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace: 'RGB' | 'HSV' = 'RGB',\n options: InterpolationOptions = {}\n): string | number {\n 'worklet';\n if (colorSpace === 'HSV') {\n return interpolateColorsHSV(\n value,\n inputRange,\n getInterpolateHSV(outputRange),\n options\n );\n } else if (colorSpace === 'RGB') {\n return interpolateColorsRGB(\n value,\n inputRange,\n getInterpolateRGB(outputRange),\n options\n );\n }\n throw new Error(\n `[Reanimated] Invalid color space provided: ${colorSpace}. Supported values are: ['RGB', 'HSV'].`\n );\n}\n\nexport enum ColorSpace {\n RGB = 0,\n HSV = 1,\n}\n\nexport interface InterpolateConfig {\n inputRange: readonly number[];\n outputRange: readonly (string | number)[];\n colorSpace: ColorSpace;\n cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;\n options: InterpolationOptions;\n}\n\nexport function useInterpolateConfig(\n inputRange: readonly number[],\n outputRange: readonly (string | number)[],\n colorSpace = ColorSpace.RGB,\n options: InterpolationOptions = {}\n): SharedValue<InterpolateConfig> {\n return useSharedValue<InterpolateConfig>({\n inputRange,\n outputRange,\n colorSpace,\n cache: makeMutable<InterpolateRGB | InterpolateHSV | null>(null),\n options,\n });\n}\n"],"mappings":"AAAA,YAAY;;AACZ,SACEA,UAAU,EACVC,QAAQ,EACRC,SAAS,EACTC,YAAY,EACZC,GAAG,EACHC,KAAK,EACLC,IAAI,EACJC,OAAO,QACF,UAAU;AACjB,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,aAAa,EAAEC,WAAW,QAAQ,iBAAiB;AAE5D,SAASC,cAAc,QAAQ,uBAAuB;;AAEtD;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GAAGH,aAAa;;AAExC;AACA;AACA;AACA;AACA;AACA;;AAMA,MAAMI,oBAAoB,GAAGA,CAC3BC,KAAa,EACbC,UAA6B,EAC7BC,MAAsB,EACtBC,OAA6B,KAC1B;EACH,SAAS;;EACT,IAAIC,CAAC,GAAG,CAAC;EACT,MAAM;IAAEC,4BAA4B,GAAG;EAAK,CAAC,GAAGF,OAAO;EACvD,IAAIE,4BAA4B,EAAE;IAChC;IACA;IACA;IACA;IACA,MAAMC,mBAAmB,GAAG,CAACL,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAMM,SAAS,GAAGL,MAAM,CAACE,CAAC;IAC1B,MAAMI,UAAU,GAAG,CAACD,SAAS,CAAC,CAAC,CAAC,CAAC;IAEjC,KAAK,IAAIE,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,SAAS,CAACG,MAAM,EAAE,EAAED,CAAC,EAAE;MACzC,MAAME,CAAC,GAAGJ,SAAS,CAACE,CAAC,CAAC,GAAGF,SAAS,CAACE,CAAC,GAAG,CAAC,CAAC;MACzC,IAAIF,SAAS,CAACE,CAAC,CAAC,GAAGF,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sC,WAAW;IACXC,UAAU;IACVM,KAAK,EAAEpD,WAAW,CAAyC,IAAI,CAAC;IAChES;EACF,CAAC,CAAC;AACJ"}
|
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Extrapolation type.
|
|
5
|
+
*
|
|
6
|
+
* @param IDENTITY - Returns the provided value as is.
|
|
7
|
+
* @param CLAMP - Clamps the value to the edge of the output range.
|
|
8
|
+
* @param EXTEND - Predicts the values beyond the output range.
|
|
9
|
+
*/
|
|
3
10
|
export let Extrapolation = /*#__PURE__*/function (Extrapolation) {
|
|
4
11
|
Extrapolation["IDENTITY"] = "identity";
|
|
5
12
|
Extrapolation["CLAMP"] = "clamp";
|
|
6
13
|
Extrapolation["EXTEND"] = "extend";
|
|
7
14
|
return Extrapolation;
|
|
8
15
|
}({});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Represents the possible values for extrapolation as a string.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Allows to specify extrapolation for left and right edge of the interpolation.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Configuration options for extrapolation.
|
|
27
|
+
*/
|
|
28
|
+
|
|
9
29
|
function getVal(type, coef, val, leftEdgeOutput, rightEdgeOutput, x) {
|
|
10
30
|
'worklet';
|
|
11
31
|
|
|
@@ -83,35 +103,43 @@ function internalInterpolate(x, narrowedInput, extrapolationConfig) {
|
|
|
83
103
|
return val;
|
|
84
104
|
}
|
|
85
105
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Lets you map a value from one range to another using linear interpolation.
|
|
108
|
+
*
|
|
109
|
+
* @param value - A number from the `input` range that is going to be mapped to the `output` range.
|
|
110
|
+
* @param inputRange - An array of numbers specifying the input range of the interpolation.
|
|
111
|
+
* @param outputRange - An array of numbers specifying the output range of the interpolation.
|
|
112
|
+
* @param extrapolate - determines what happens when the `value` goes beyond the `input` range. Defaults to `Extrapolation.EXTEND` - {@link ExtrapolationType}.
|
|
113
|
+
* @returns A mapped value within the output range.
|
|
114
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/interpolate
|
|
115
|
+
*/
|
|
116
|
+
export function interpolate(x, inputRange, outputRange, type) {
|
|
89
117
|
'worklet';
|
|
90
118
|
|
|
91
|
-
if (
|
|
92
|
-
throw new Error('[Reanimated] Interpolation input and output should contain at least two values.');
|
|
119
|
+
if (inputRange.length < 2 || outputRange.length < 2) {
|
|
120
|
+
throw new Error('[Reanimated] Interpolation input and output ranges should contain at least two values.');
|
|
93
121
|
}
|
|
94
122
|
const extrapolationConfig = validateType(type);
|
|
95
|
-
const length =
|
|
123
|
+
const length = inputRange.length;
|
|
96
124
|
const narrowedInput = {
|
|
97
|
-
leftEdgeInput:
|
|
98
|
-
rightEdgeInput:
|
|
99
|
-
leftEdgeOutput:
|
|
100
|
-
rightEdgeOutput:
|
|
125
|
+
leftEdgeInput: inputRange[0],
|
|
126
|
+
rightEdgeInput: inputRange[1],
|
|
127
|
+
leftEdgeOutput: outputRange[0],
|
|
128
|
+
rightEdgeOutput: outputRange[1]
|
|
101
129
|
};
|
|
102
130
|
if (length > 2) {
|
|
103
|
-
if (x >
|
|
104
|
-
narrowedInput.leftEdgeInput =
|
|
105
|
-
narrowedInput.rightEdgeInput =
|
|
106
|
-
narrowedInput.leftEdgeOutput =
|
|
107
|
-
narrowedInput.rightEdgeOutput =
|
|
131
|
+
if (x > inputRange[length - 1]) {
|
|
132
|
+
narrowedInput.leftEdgeInput = inputRange[length - 2];
|
|
133
|
+
narrowedInput.rightEdgeInput = inputRange[length - 1];
|
|
134
|
+
narrowedInput.leftEdgeOutput = outputRange[length - 2];
|
|
135
|
+
narrowedInput.rightEdgeOutput = outputRange[length - 1];
|
|
108
136
|
} else {
|
|
109
137
|
for (let i = 1; i < length; ++i) {
|
|
110
|
-
if (x <=
|
|
111
|
-
narrowedInput.leftEdgeInput =
|
|
112
|
-
narrowedInput.rightEdgeInput =
|
|
113
|
-
narrowedInput.leftEdgeOutput =
|
|
114
|
-
narrowedInput.rightEdgeOutput =
|
|
138
|
+
if (x <= inputRange[i]) {
|
|
139
|
+
narrowedInput.leftEdgeInput = inputRange[i - 1];
|
|
140
|
+
narrowedInput.rightEdgeInput = inputRange[i];
|
|
141
|
+
narrowedInput.leftEdgeOutput = outputRange[i - 1];
|
|
142
|
+
narrowedInput.rightEdgeOutput = outputRange[i];
|
|
115
143
|
break;
|
|
116
144
|
}
|
|
117
145
|
}
|
|
@@ -121,11 +149,13 @@ export function interpolate(x, input, output, type) {
|
|
|
121
149
|
}
|
|
122
150
|
|
|
123
151
|
/**
|
|
124
|
-
*
|
|
152
|
+
* Lets you limit a value within a specified range.
|
|
125
153
|
*
|
|
126
154
|
* @param value - A number that will be returned as long as the provided value is in range between `min` and `max`.
|
|
127
155
|
* @param min - A number which will be returned when provided `value` is lower than `min`.
|
|
128
156
|
* @param max - A number which will be returned when provided `value` is higher than `max`.
|
|
157
|
+
* @returns A number between min and max bounds.
|
|
158
|
+
* @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/clamp/
|
|
129
159
|
*/
|
|
130
160
|
export function clamp(value, min, max) {
|
|
131
161
|
'worklet';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Extrapolation","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateType","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","input","output","length","i","clamp","min","max","Math"],"sources":["interpolation.ts"],"sourcesContent":["'use strict';\n\nexport enum Extrapolation {\n IDENTITY = 'identity',\n CLAMP = 'clamp',\n EXTEND = 'extend',\n}\n\ntype ExtrapolationAsString = 'identity' | 'clamp' | 'extend';\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolation | string;\n extrapolateRight?: Extrapolation | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolation;\n extrapolateRight: Extrapolation;\n}\n\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolation\n | ExtrapolationAsString\n | undefined;\n\nfunction getVal(\n type: Extrapolation,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n 'worklet';\n\n switch (type) {\n case Extrapolation.IDENTITY:\n return x;\n case Extrapolation.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolation.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolation {\n 'worklet';\n\n return (\n value === Extrapolation.EXTEND ||\n value === Extrapolation.CLAMP ||\n value === Extrapolation.IDENTITY\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nfunction validateType(type: ExtrapolationType): RequiredExtrapolationConfig {\n 'worklet';\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolation.EXTEND,\n extrapolateRight: Extrapolation.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === 'string') {\n if (!isExtrapolate(type)) {\n throw new Error(\n `[Reanimated] Unsupported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `[Reanimated] Unsupported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n 'worklet';\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) return leftEdgeOutput;\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n// TODO: support default values in worklets:\n// e.g. function interpolate(x, input, output, type = Extrapolatation.CLAMP)\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n type?: ExtrapolationType\n): number {\n 'worklet';\n if (input.length < 2 || output.length < 2) {\n throw new Error(\n '[Reanimated] Interpolation input and output should contain at least two values.'\n );\n }\n\n const extrapolationConfig = validateType(type);\n const length = input.length;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: input[0],\n rightEdgeInput: input[1],\n leftEdgeOutput: output[0],\n rightEdgeOutput: output[1],\n };\n if (length > 2) {\n if (x > input[length - 1]) {\n narrowedInput.leftEdgeInput = input[length - 2];\n narrowedInput.rightEdgeInput = input[length - 1];\n narrowedInput.leftEdgeOutput = output[length - 2];\n narrowedInput.rightEdgeOutput = output[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= input[i]) {\n narrowedInput.leftEdgeInput = input[i - 1];\n narrowedInput.rightEdgeInput = input[i];\n narrowedInput.leftEdgeOutput = output[i - 1];\n narrowedInput.rightEdgeOutput = output[i];\n break;\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig);\n}\n\n/**\n * `clamp` lets you limit a value within a specified range.\n *\n * @param value - A number that will be returned as long as the provided value is in range between `min` and `max`.\n * @param min - A number which will be returned when provided `value` is lower than `min`.\n * @param max - A number which will be returned when provided `value` is higher than `max`.\n */\nexport function clamp(value: number, min: number, max: number) {\n 'worklet';\n return Math.min(Math.max(value, min), max);\n}\n"],"mappings":"AAAA,YAAY;;AAEZ,WAAYA,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AA+BzB,SAASC,MAAMA,CACbC,IAAmB,EACnBC,IAAY,EACZC,GAAW,EACXC,cAAsB,EACtBC,eAAuB,EACvBC,CAAS,EACD;EACR,SAAS;;EAET,QAAQL,IAAI;IACV,KAAKF,aAAa,CAACQ,QAAQ;MACzB,OAAOD,CAAC;IACV,KAAKP,aAAa,CAACS,KAAK;MACtB,IAAIN,IAAI,GAAGC,GAAG,GAAGD,IAAI,GAAGE,cAAc,EAAE;QACtC,OAAOA,cAAc;MACvB;MACA,OAAOC,eAAe;IACxB,KAAKN,aAAa,CAACU,MAAM;IACzB;MACE,OAAON,GAAG;EAAC;AAEjB;AAEA,SAASO,aAAaA,CAACC,KAAa,EAA0B;EAC5D,SAAS;;EAET,OACEA,KAAK,KAAKZ,aAAa,CAACU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AG,CAAC,CAAC,EAAE;MACzBP,aAAa,CAACC,aAAa,GAAGI,KAAK,CAACE,MAAM,GAAG,CAAC,CAAC;MAC/CP,aAAa,CAACE,cAAc,GAAGG,KAAK,CAACE,MAAM,GAAG,CAAC,CAAC;MAChDP,aAAa,CAAChB,cAAc,GAAGsB,MAAM,CAACC,MAAM,GAAG,CAAC,CAAC;MACjDP,aAAa,CAACf,eAAe,GAAGqB,MAAM,CAACC,MAAM,GAAG,CAAC,CAAC;IACpD,CAAC,MAAM;MACL,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,MAAM,EAAE,EAAEC,CAAC,EAAE;QAC/B,IAAItB,CAAC,IAAImB,KAAK,CAACG,CAAC,CAAC,EAAE;UACjBR,aAAa,CAACC,aAAa,GAAGI,KAAK,CAACG,CAAC,GAAG,CAAC,CAAC;UAC1CR,aAAa,CAACE,cAAc,GAAGG,KAAK,CAACG,CAAC,CAAC;UACvCR,aAAa,CAAChB,cAAc,GAAGsB,MAAM,CAACE,CAAC,GAAG,CAAC,CAAC;UAC5CR,aAAa,CAACf,eAAe,GAAGqB,MAAM,CAACE,CAAC,CAAC;UACzC;QACF;MACF;IACF;EACF;EAEA,OAAOT,mBAAmB,CAACb,CAAC,EAAEc,aAAa,EAAEP,mBAAmB,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASgB,KAAKA,CAAClB,KAAa,EAAEmB,GAAW,EAAEC,GAAW,EAAE;EAC7D,SAAS;;EACT,OAAOC,IAAI,CAACF,GAAG,CAACE,IAAI,CAACD,GAAG,CAACpB,KAAK,EAAEmB,GAAG,CAAC,EAAEC,GAAG,CAAC;AAC5C"}
|
|
1
|
+
{"version":3,"names":["Extrapolation","getVal","type","coef","val","leftEdgeOutput","rightEdgeOutput","x","IDENTITY","CLAMP","EXTEND","isExtrapolate","value","validateType","extrapolationConfig","extrapolateLeft","extrapolateRight","Error","Object","assign","internalInterpolate","narrowedInput","leftEdgeInput","rightEdgeInput","progress","interpolate","inputRange","outputRange","length","i","clamp","min","max","Math"],"sources":["interpolation.ts"],"sourcesContent":["'use strict';\n\n/**\n * Extrapolation type.\n *\n * @param IDENTITY - Returns the provided value as is.\n * @param CLAMP - Clamps the value to the edge of the output range.\n * @param EXTEND - Predicts the values beyond the output range.\n */\nexport enum Extrapolation {\n IDENTITY = 'identity',\n CLAMP = 'clamp',\n EXTEND = 'extend',\n}\n\n/**\n * Represents the possible values for extrapolation as a string.\n */\ntype ExtrapolationAsString = 'identity' | 'clamp' | 'extend';\n\ninterface InterpolationNarrowedInput {\n leftEdgeInput: number;\n rightEdgeInput: number;\n leftEdgeOutput: number;\n rightEdgeOutput: number;\n}\n\n/**\n * Allows to specify extrapolation for left and right edge of the interpolation.\n */\nexport interface ExtrapolationConfig {\n extrapolateLeft?: Extrapolation | string;\n extrapolateRight?: Extrapolation | string;\n}\n\ninterface RequiredExtrapolationConfig {\n extrapolateLeft: Extrapolation;\n extrapolateRight: Extrapolation;\n}\n\n/**\n * Configuration options for extrapolation.\n */\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolation\n | ExtrapolationAsString\n | undefined;\n\nfunction getVal(\n type: Extrapolation,\n coef: number,\n val: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n x: number\n): number {\n 'worklet';\n\n switch (type) {\n case Extrapolation.IDENTITY:\n return x;\n case Extrapolation.CLAMP:\n if (coef * val < coef * leftEdgeOutput) {\n return leftEdgeOutput;\n }\n return rightEdgeOutput;\n case Extrapolation.EXTEND:\n default:\n return val;\n }\n}\n\nfunction isExtrapolate(value: string): value is Extrapolation {\n 'worklet';\n\n return (\n value === Extrapolation.EXTEND ||\n value === Extrapolation.CLAMP ||\n value === Extrapolation.IDENTITY\n );\n}\n\n// validates extrapolations type\n// if type is correct, converts it to ExtrapolationConfig\nfunction validateType(type: ExtrapolationType): RequiredExtrapolationConfig {\n 'worklet';\n // initialize extrapolationConfig with default extrapolation\n const extrapolationConfig: RequiredExtrapolationConfig = {\n extrapolateLeft: Extrapolation.EXTEND,\n extrapolateRight: Extrapolation.EXTEND,\n };\n\n if (!type) {\n return extrapolationConfig;\n }\n\n if (typeof type === 'string') {\n if (!isExtrapolate(type)) {\n throw new Error(\n `[Reanimated] Unsupported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], \"clamp\")`\n );\n }\n extrapolationConfig.extrapolateLeft = type;\n extrapolationConfig.extrapolateRight = type;\n return extrapolationConfig;\n }\n\n // otherwise type is extrapolation config object\n if (\n (type.extrapolateLeft && !isExtrapolate(type.extrapolateLeft)) ||\n (type.extrapolateRight && !isExtrapolate(type.extrapolateRight))\n ) {\n throw new Error(\n `[Reanimated] Unsupported value for \"interpolate\" \\nSupported values: [\"extend\", \"clamp\", \"identity\", Extrapolatation.CLAMP, Extrapolatation.EXTEND, Extrapolatation.IDENTITY]\\n Valid example:\n interpolate(value, [inputRange], [outputRange], {\n extrapolateLeft: Extrapolation.CLAMP,\n extrapolateRight: Extrapolation.IDENTITY\n }})`\n );\n }\n\n Object.assign(extrapolationConfig, type);\n return extrapolationConfig;\n}\n\nfunction internalInterpolate(\n x: number,\n narrowedInput: InterpolationNarrowedInput,\n extrapolationConfig: RequiredExtrapolationConfig\n) {\n 'worklet';\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n narrowedInput;\n if (rightEdgeInput - leftEdgeInput === 0) return leftEdgeOutput;\n const progress = (x - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);\n const val = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);\n const coef = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;\n\n if (coef * val < coef * leftEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateLeft,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n } else if (coef * val > coef * rightEdgeOutput) {\n return getVal(\n extrapolationConfig.extrapolateRight,\n coef,\n val,\n leftEdgeOutput,\n rightEdgeOutput,\n x\n );\n }\n\n return val;\n}\n\n/**\n * Lets you map a value from one range to another using linear interpolation.\n *\n * @param value - A number from the `input` range that is going to be mapped to the `output` range.\n * @param inputRange - An array of numbers specifying the input range of the interpolation.\n * @param outputRange - An array of numbers specifying the output range of the interpolation.\n * @param extrapolate - determines what happens when the `value` goes beyond the `input` range. Defaults to `Extrapolation.EXTEND` - {@link ExtrapolationType}.\n * @returns A mapped value within the output range.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/interpolate\n */\nexport function interpolate(\n x: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n type?: ExtrapolationType\n): number {\n 'worklet';\n if (inputRange.length < 2 || outputRange.length < 2) {\n throw new Error(\n '[Reanimated] Interpolation input and output ranges should contain at least two values.'\n );\n }\n\n const extrapolationConfig = validateType(type);\n const length = inputRange.length;\n const narrowedInput: InterpolationNarrowedInput = {\n leftEdgeInput: inputRange[0],\n rightEdgeInput: inputRange[1],\n leftEdgeOutput: outputRange[0],\n rightEdgeOutput: outputRange[1],\n };\n if (length > 2) {\n if (x > inputRange[length - 1]) {\n narrowedInput.leftEdgeInput = inputRange[length - 2];\n narrowedInput.rightEdgeInput = inputRange[length - 1];\n narrowedInput.leftEdgeOutput = outputRange[length - 2];\n narrowedInput.rightEdgeOutput = outputRange[length - 1];\n } else {\n for (let i = 1; i < length; ++i) {\n if (x <= inputRange[i]) {\n narrowedInput.leftEdgeInput = inputRange[i - 1];\n narrowedInput.rightEdgeInput = inputRange[i];\n narrowedInput.leftEdgeOutput = outputRange[i - 1];\n narrowedInput.rightEdgeOutput = outputRange[i];\n break;\n }\n }\n }\n }\n\n return internalInterpolate(x, narrowedInput, extrapolationConfig);\n}\n\n/**\n * Lets you limit a value within a specified range.\n *\n * @param value - A number that will be returned as long as the provided value is in range between `min` and `max`.\n * @param min - A number which will be returned when provided `value` is lower than `min`.\n * @param max - A number which will be returned when provided `value` is higher than `max`.\n * @returns A number between min and max bounds.\n * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/clamp/\n */\nexport function clamp(value: number, min: number, max: number) {\n 'worklet';\n return Math.min(Math.max(value, min), max);\n}\n"],"mappings":"AAAA,YAAY;;AAEZ;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAYA,aAAa,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;;AAMzB;AACA;AACA;;AAUA;AACA;AACA;;AAWA;AACA;AACA;;AAOA,SAASC,MAAMA,CACbC,IAAmB,EACnBC,IAAY,EACZC,GAAW,EACXC,cAAsB,EACtBC,eAAuB,EACvBC,CAAS,EACD;EACR,SAAS;;EAET,QAAQL,IAAI;IACV,KAAKF,aAAa,CAACQ,QAAQ;MACzB,OAAOD,CAAC;IACV,KAAKP,aAAa,CAACS,KAAK;MACtB,IAAIN,IAAI,GAAGC,GAAG,GAAGD,IAAI,GAAGE,cAAc,EAAE;QACtC,OAAOA,cAAc;MACvB;MACA,OAAOC,eAAe;IACxB,KAAKN,aAAa,CAACU,MAAM;IACzB;MACE,OAAON,GAAG;EAAC;AAEjB;AAEA,SAASO,aAAaA,CAACC,KAAa,EAA0B;EAC5D,SAAS;;EAET,OACEA,KAAK,KAAKZ,aAAa,CAACU,MAAM,IAC9BE,KAAK,KAAKZ,aAAa,CAACS,KAAK,IAC7BG,KAAK,KAAKZ,aAAa,CAACQ,QAAQ;AAEpC;;AAEA;AACA;AACA,SAASK,YAAYA,CAACX,IAAuB,EAA+B;EAC1E,SAAS;;EACT;EACA,MAAMY,mBAAgD,GAAG;IACvDC,eAAe,EAAEf,aAAa,CAACU,MAAM;IACrCM,gBAAgB,EAAEhB,aAAa,CAACU;EAClC,CAAC;EAED,IAAI,CAACR,IAAI,EAAE;IACT,OAAOY,mBAAmB;EAC5B;EAEA,IAAI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CAAC,MAAM;MACL,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,MAAM,EAAE,EAAEC,CAAC,EAAE;QAC/B,IAAItB,CAAC,IAAImB,UAAU,CAACG,CAAC,CAAC,EAAE;UACtBR,aAAa,CAACC,aAAa,GAAGI,UAAU,CAACG,CAAC,GAAG,CAAC,CAAC;UAC/CR,aAAa,CAACE,cAAc,GAAGG,UAAU,CAACG,CAAC,CAAC;UAC5CR,aAAa,CAAChB,cAAc,GAAGsB,WAAW,CAACE,CAAC,GAAG,CAAC,CAAC;UACjDR,aAAa,CAACf,eAAe,GAAGqB,WAAW,CAACE,CAAC,CAAC;UAC9C;QACF;MACF;IACF;EACF;EAEA,OAAOT,mBAAmB,CAACb,CAAC,EAAEc,aAAa,EAAEP,mBAAmB,CAAC;AACnE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASgB,KAAKA,CAAClB,KAAa,EAAEmB,GAAW,EAAEC,GAAW,EAAE;EAC7D,SAAS;;EACT,OAAOC,IAAI,CAACF,GAAG,CAACE,IAAI,CAACD,GAAG,CAACpB,KAAK,EAAEmB,GAAG,CAAC,EAAEC,GAAG,CAAC;AAC5C"}
|
|
@@ -17,6 +17,11 @@ export class BaseAnimationBuilder {
|
|
|
17
17
|
throw new Error('[Reanimated] Unimplemented method in child class.');
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Lets you adjust the animation duration. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
|
|
22
|
+
*
|
|
23
|
+
* @param durationMs - Length of the animation (in milliseconds).
|
|
24
|
+
*/
|
|
20
25
|
static duration(durationMs) {
|
|
21
26
|
const instance = this.createInstance();
|
|
22
27
|
return instance.duration(durationMs);
|
|
@@ -25,6 +30,12 @@ export class BaseAnimationBuilder {
|
|
|
25
30
|
this.durationV = durationMs;
|
|
26
31
|
return this;
|
|
27
32
|
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Lets you adjust the delay before the animation starts (in milliseconds). Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
|
|
36
|
+
*
|
|
37
|
+
* @param delayMs - Delay before the animation starts (in milliseconds).
|
|
38
|
+
*/
|
|
28
39
|
static delay(delayMs) {
|
|
29
40
|
const instance = this.createInstance();
|
|
30
41
|
return instance.delay(delayMs);
|
|
@@ -33,6 +44,12 @@ export class BaseAnimationBuilder {
|
|
|
33
44
|
this.delayV = delayMs;
|
|
34
45
|
return this;
|
|
35
46
|
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The callback that will fire after the animation ends. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
|
|
50
|
+
*
|
|
51
|
+
* @param callback - Callback that will fire after the animation ends.
|
|
52
|
+
*/
|
|
36
53
|
static withCallback(callback) {
|
|
37
54
|
const instance = this.createInstance();
|
|
38
55
|
return instance.withCallback(callback);
|
|
@@ -41,9 +58,15 @@ export class BaseAnimationBuilder {
|
|
|
41
58
|
this.callbackV = callback;
|
|
42
59
|
return this;
|
|
43
60
|
}
|
|
44
|
-
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Lets you adjust the behavior when the device's reduced motion accessibility setting is turned on. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
|
|
64
|
+
*
|
|
65
|
+
* @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.
|
|
66
|
+
*/
|
|
67
|
+
static reduceMotion(reduceMotion) {
|
|
45
68
|
const instance = this.createInstance();
|
|
46
|
-
return instance.reduceMotion(
|
|
69
|
+
return instance.reduceMotion(reduceMotion);
|
|
47
70
|
}
|
|
48
71
|
reduceMotion(reduceMotionV) {
|
|
49
72
|
this.reduceMotionV = reduceMotionV;
|
|
@@ -57,6 +80,10 @@ export class BaseAnimationBuilder {
|
|
|
57
80
|
getDuration() {
|
|
58
81
|
return this.durationV ?? 300;
|
|
59
82
|
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated Use `.delay()` with `Math.random()` instead
|
|
86
|
+
*/
|
|
60
87
|
static randomDelay() {
|
|
61
88
|
const instance = this.createInstance();
|
|
62
89
|
return instance.randomDelay();
|
package/lib/module/reanimated2/layoutReanimation/animationBuilder/BaseAnimationBuilder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","withDelay","ReduceMotion","getReduceMotionFromConfig","BaseAnimationBuilder","constructor","System","Error","duration","durationMs","instance","createInstance","durationV","delay","delayMs","delayV","withCallback","callback","callbackV","reduceMotion","reduceMotionV","getDuration","randomDelay","randomizeDelay","getDelay","Math","random","getReduceMotion","getDelayFunction","isDelayProvided","animation","_","build"],"sources":["BaseAnimationBuilder.ts"],"sourcesContent":["'use strict';\nimport { withDelay } from '../../animation';\nimport type {\n EntryExitAnimationFunction,\n AnimationFunction,\n LayoutAnimationFunction,\n} from './commonTypes';\n\nimport { ReduceMotion } from '../../commonTypes';\nimport { getReduceMotionFromConfig } from '../../animation/util';\n\nexport class BaseAnimationBuilder {\n durationV?: number;\n delayV?: number;\n reduceMotionV: ReduceMotion = ReduceMotion.System;\n randomizeDelay = false;\n callbackV?: (finished: boolean) => void;\n\n static createInstance: <T extends typeof BaseAnimationBuilder>(\n this: T\n ) => InstanceType<T>;\n\n build = (): EntryExitAnimationFunction | LayoutAnimationFunction => {\n throw new Error('[Reanimated] Unimplemented method in child class.');\n };\n\n static duration<T extends typeof BaseAnimationBuilder>(\n this: T,\n durationMs: number\n ): InstanceType<T> {\n const instance = this.createInstance();\n return instance.duration(durationMs);\n }\n\n duration(durationMs: number): this {\n this.durationV = durationMs;\n return this;\n }\n\n static delay<T extends typeof BaseAnimationBuilder>(\n this: T,\n delayMs: number\n ): InstanceType<T> {\n const instance = this.createInstance();\n return instance.delay(delayMs);\n }\n\n delay(delayMs: number): this {\n this.delayV = delayMs;\n return this;\n }\n\n static withCallback<T extends typeof BaseAnimationBuilder>(\n this: T,\n callback: (finished: boolean) => void\n ): InstanceType<T> {\n const instance = this.createInstance();\n return instance.withCallback(callback);\n }\n\n withCallback(callback: (
|
|
1
|
+
{"version":3,"names":["_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","withDelay","ReduceMotion","getReduceMotionFromConfig","BaseAnimationBuilder","constructor","System","Error","duration","durationMs","instance","createInstance","durationV","delay","delayMs","delayV","withCallback","callback","callbackV","reduceMotion","reduceMotionV","getDuration","randomDelay","randomizeDelay","getDelay","Math","random","getReduceMotion","getDelayFunction","isDelayProvided","animation","_","build"],"sources":["BaseAnimationBuilder.ts"],"sourcesContent":["'use strict';\nimport { withDelay } from '../../animation';\nimport type {\n EntryExitAnimationFunction,\n AnimationFunction,\n LayoutAnimationFunction,\n} from './commonTypes';\n\nimport { ReduceMotion } from '../../commonTypes';\nimport { getReduceMotionFromConfig } from '../../animation/util';\n\nexport class BaseAnimationBuilder {\n durationV?: number;\n delayV?: number;\n reduceMotionV: ReduceMotion = ReduceMotion.System;\n randomizeDelay = false;\n callbackV?: (finished: boolean) => void;\n\n static createInstance: <T extends typeof BaseAnimationBuilder>(\n this: T\n ) => InstanceType<T>;\n\n build = (): EntryExitAnimationFunction | LayoutAnimationFunction => {\n throw new Error('[Reanimated] Unimplemented method in child class.');\n };\n\n /**\n * Lets you adjust the animation duration. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param durationMs - Length of the animation (in milliseconds).\n */\n static duration<T extends typeof BaseAnimationBuilder>(\n this: T,\n durationMs: number\n ): InstanceType<T> {\n const instance = this.createInstance();\n return instance.duration(durationMs);\n }\n\n duration(durationMs: number): this {\n this.durationV = durationMs;\n return this;\n }\n\n /**\n * Lets you adjust the delay before the animation starts (in milliseconds). Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param delayMs - Delay before the animation starts (in milliseconds).\n */\n static delay<T extends typeof BaseAnimationBuilder>(\n this: T,\n delayMs: number\n ): InstanceType<T> {\n const instance = this.createInstance();\n return instance.delay(delayMs);\n }\n\n delay(delayMs: number): this {\n this.delayV = delayMs;\n return this;\n }\n\n /**\n * The callback that will fire after the animation ends. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param callback - Callback that will fire after the animation ends.\n */\n static withCallback<T extends typeof BaseAnimationBuilder>(\n this: T,\n callback: (finished: boolean) => void\n ): InstanceType<T> {\n const instance = this.createInstance();\n return instance.withCallback(callback);\n }\n\n withCallback(callback: (finished: boolean) => void): this {\n this.callbackV = callback;\n return this;\n }\n\n /**\n * Lets you adjust the behavior when the device's reduced motion accessibility setting is turned on. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param reduceMotion - Determines how the animation responds to the device's reduced motion accessibility setting. Default to `ReduceMotion.System` - {@link ReduceMotion}.\n */\n static reduceMotion<T extends typeof BaseAnimationBuilder>(\n this: T,\n reduceMotion: ReduceMotion\n ): InstanceType<T> {\n const instance = this.createInstance();\n return instance.reduceMotion(reduceMotion);\n }\n\n reduceMotion(reduceMotionV: ReduceMotion): this {\n this.reduceMotionV = reduceMotionV;\n return this;\n }\n\n // 300ms is the default animation duration. If any animation has different default has to override this method.\n static getDuration(): number {\n return 300;\n }\n\n getDuration(): number {\n return this.durationV ?? 300;\n }\n\n /**\n * @deprecated Use `.delay()` with `Math.random()` instead\n */\n static randomDelay<T extends typeof BaseAnimationBuilder>(\n this: T\n ): InstanceType<T> {\n const instance = this.createInstance();\n return instance.randomDelay();\n }\n\n randomDelay(): this {\n this.randomizeDelay = true;\n return this;\n }\n\n // when randomizeDelay is set to true, randomize delay between 0 and provided value (or 1000ms if delay is not provided)\n getDelay(): number {\n return this.randomizeDelay\n ? Math.random() * (this.delayV ?? 1000)\n : this.delayV ?? 0;\n }\n\n getReduceMotion(): ReduceMotion {\n return this.reduceMotionV;\n }\n\n getDelayFunction(): AnimationFunction {\n const isDelayProvided = this.randomizeDelay || this.delayV;\n const reduceMotion = this.getReduceMotion();\n return isDelayProvided\n ? (delay, animation) => {\n 'worklet';\n return withDelay(delay, animation, reduceMotion);\n }\n : (_, animation) => {\n 'worklet';\n animation.reduceMotion = getReduceMotionFromConfig(reduceMotion);\n return animation;\n };\n }\n\n static build<T extends typeof BaseAnimationBuilder>(\n this: T\n ): EntryExitAnimationFunction | LayoutAnimationFunction {\n const instance = this.createInstance();\n return instance.build();\n }\n}\n"],"mappings":"AAAA,YAAY;;AAAC,SAAAA,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAA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,eAAe,EAAE;IAC3C,OAAOE,eAAe,GAClB,CAAChB,KAAK,EAAEiB,SAAS,KAAK;MACpB,SAAS;;MACT,OAAO7B,SAAS,CAACY,KAAK,EAAEiB,SAAS,EAAEX,YAAY,CAAC;IAClD,CAAC,GACD,CAACY,CAAC,EAAED,SAAS,KAAK;MAChB,SAAS;;MACTA,SAAS,CAACX,YAAY,GAAGhB,yBAAyB,CAACgB,YAAY,CAAC;MAChE,OAAOW,SAAS;IAClB,CAAC;EACP;EAEA,OAAOE,KAAKA,CAAA,EAE4C;IACtD,MAAMtB,QAAQ,GAAG,IAAI,CAACC,cAAc,EAAE;IACtC,OAAOD,QAAQ,CAACsB,KAAK,EAAE;EACzB;AACF;AAACtD,eAAA,CA/IY0B,oBAAoB"}
|
package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js
CHANGED
|
@@ -20,6 +20,11 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
|
|
|
20
20
|
_defineProperty(this, "restSpeedThresholdV", void 0);
|
|
21
21
|
_defineProperty(this, "initialValues", void 0);
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Lets you change the easing curve of the animation. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
|
|
25
|
+
*
|
|
26
|
+
* @param easingFunction - An easing function which defines the animation curve.
|
|
27
|
+
*/
|
|
23
28
|
static easing(easingFunction) {
|
|
24
29
|
const instance = this.createInstance();
|
|
25
30
|
return instance.easing(easingFunction);
|
|
@@ -28,6 +33,12 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
|
|
|
28
33
|
this.easingV = easingFunction;
|
|
29
34
|
return this;
|
|
30
35
|
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Lets you rotate the element. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
|
|
39
|
+
*
|
|
40
|
+
* @param degree - The rotation degree.
|
|
41
|
+
*/
|
|
31
42
|
static rotate(degree) {
|
|
32
43
|
const instance = this.createInstance();
|
|
33
44
|
return instance.rotate(degree);
|
|
@@ -36,6 +47,12 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
|
|
|
36
47
|
this.rotateV = degree;
|
|
37
48
|
return this;
|
|
38
49
|
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Enables the spring-based animation configuration. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
|
|
53
|
+
*
|
|
54
|
+
* @param duration - An optional duration of the spring animation (in milliseconds).
|
|
55
|
+
*/
|
|
39
56
|
static springify(duration) {
|
|
40
57
|
const instance = this.createInstance();
|
|
41
58
|
return instance.springify(duration);
|
|
@@ -45,14 +62,26 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
|
|
|
45
62
|
this.type = withSpring;
|
|
46
63
|
return this;
|
|
47
64
|
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Lets you adjust the spring animation damping ratio. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
|
|
68
|
+
*
|
|
69
|
+
* @param dampingRatio - How damped the spring is.
|
|
70
|
+
*/
|
|
48
71
|
static dampingRatio(dampingRatio) {
|
|
49
72
|
const instance = this.createInstance();
|
|
50
73
|
return instance.dampingRatio(dampingRatio);
|
|
51
74
|
}
|
|
52
|
-
dampingRatio(
|
|
53
|
-
this.dampingRatioV =
|
|
75
|
+
dampingRatio(value) {
|
|
76
|
+
this.dampingRatioV = value;
|
|
54
77
|
return this;
|
|
55
78
|
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Lets you adjust the spring animation damping. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
|
|
82
|
+
*
|
|
83
|
+
* @param value - Decides how quickly a spring stops moving. Higher damping means the spring will come to rest faster.
|
|
84
|
+
*/
|
|
56
85
|
static damping(damping) {
|
|
57
86
|
const instance = this.createInstance();
|
|
58
87
|
return instance.damping(damping);
|
|
@@ -61,6 +90,12 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
|
|
|
61
90
|
this.dampingV = damping;
|
|
62
91
|
return this;
|
|
63
92
|
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Lets you adjust the spring animation mass. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
|
|
96
|
+
*
|
|
97
|
+
* @param mass - The weight of the spring. Reducing this value makes the animation faster.
|
|
98
|
+
*/
|
|
64
99
|
static mass(mass) {
|
|
65
100
|
const instance = this.createInstance();
|
|
66
101
|
return instance.mass(mass);
|
|
@@ -69,6 +104,12 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
|
|
|
69
104
|
this.massV = mass;
|
|
70
105
|
return this;
|
|
71
106
|
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Lets you adjust the stiffness of the spring animation. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
|
|
110
|
+
*
|
|
111
|
+
* @param stiffness - How bouncy the spring is.
|
|
112
|
+
*/
|
|
72
113
|
static stiffness(stiffness) {
|
|
73
114
|
const instance = this.createInstance();
|
|
74
115
|
return instance.stiffness(stiffness);
|
|
@@ -77,6 +118,12 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
|
|
|
77
118
|
this.stiffnessV = stiffness;
|
|
78
119
|
return this;
|
|
79
120
|
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Lets you adjust overshoot clamping of the spring. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
|
|
124
|
+
*
|
|
125
|
+
* @param overshootClamping - Whether a spring can bounce over the final position.
|
|
126
|
+
*/
|
|
80
127
|
static overshootClamping(overshootClamping) {
|
|
81
128
|
const instance = this.createInstance();
|
|
82
129
|
return instance.overshootClamping(overshootClamping);
|
|
@@ -85,6 +132,12 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
|
|
|
85
132
|
this.overshootClampingV = overshootClamping;
|
|
86
133
|
return this;
|
|
87
134
|
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Lets you adjust the rest displacement threshold of the spring animation. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
|
|
138
|
+
*
|
|
139
|
+
* @param restDisplacementThreshold - The displacement below which the spring will snap to the designated position without further oscillations.
|
|
140
|
+
*/
|
|
88
141
|
static restDisplacementThreshold(restDisplacementThreshold) {
|
|
89
142
|
const instance = this.createInstance();
|
|
90
143
|
return instance.restDisplacementThreshold(restDisplacementThreshold);
|
|
@@ -93,6 +146,12 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
|
|
|
93
146
|
this.restDisplacementThresholdV = restDisplacementThreshold;
|
|
94
147
|
return this;
|
|
95
148
|
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Lets you adjust the rest speed threshold of the spring animation. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).
|
|
152
|
+
*
|
|
153
|
+
* @param restSpeedThreshold - The speed in pixels per second from which the spring will snap to the designated position without further oscillations.
|
|
154
|
+
*/
|
|
96
155
|
static restSpeedThreshold(restSpeedThreshold) {
|
|
97
156
|
const instance = this.createInstance();
|
|
98
157
|
return instance.restSpeedThreshold(restSpeedThreshold);
|
|
@@ -101,6 +160,12 @@ export class ComplexAnimationBuilder extends BaseAnimationBuilder {
|
|
|
101
160
|
this.restSpeedThresholdV = restSpeedThreshold;
|
|
102
161
|
return this;
|
|
103
162
|
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Lets you override the initial config of the animation
|
|
166
|
+
*
|
|
167
|
+
* @param values - An object containing the styles to override.
|
|
168
|
+
*/
|
|
104
169
|
static withInitialValues(values) {
|
|
105
170
|
const instance = this.createInstance();
|
|
106
171
|
return instance.withInitialValues(values);
|
package/lib/module/reanimated2/layoutReanimation/animationBuilder/ComplexAnimationBuilder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","withTiming","withSpring","BaseAnimationBuilder","ComplexAnimationBuilder","constructor","arguments","easing","easingFunction","instance","createInstance","easingV","rotate","degree","rotateV","springify","duration","durationV","type","dampingRatio","dampingRatioV","damping","dampingV","mass","massV","stiffness","stiffnessV","overshootClamping","overshootClampingV","restDisplacementThreshold","restDisplacementThresholdV","restSpeedThreshold","restSpeedThresholdV","withInitialValues","values","initialValues","getAnimationAndConfig","animation","config","maybeSetConfigValue","variableName","forEach","_ref"],"sources":["ComplexAnimationBuilder.ts"],"sourcesContent":["'use strict';\nimport { withTiming, withSpring } from '../../animation';\nimport type {\n AnimationFunction,\n BaseBuilderAnimationConfig,\n LayoutAnimationAndConfig,\n} from './commonTypes';\nimport type { EasingFunction } from '../../Easing';\nimport { BaseAnimationBuilder } from './BaseAnimationBuilder';\nimport type { StyleProps } from '../../commonTypes';\n\nexport class ComplexAnimationBuilder extends BaseAnimationBuilder {\n easingV?: EasingFunction;\n rotateV?: string;\n type?: AnimationFunction;\n dampingV?: number;\n dampingRatioV?: number;\n massV?: number;\n stiffnessV?: number;\n overshootClampingV?: number;\n restDisplacementThresholdV?: number;\n restSpeedThresholdV?: number;\n initialValues?: StyleProps;\n\n static createInstance: <T extends typeof BaseAnimationBuilder>(\n this: T\n ) => InstanceType<T>;\n\n static easing<T extends typeof ComplexAnimationBuilder>(\n this: T,\n easingFunction: EasingFunction\n ) {\n const instance = this.createInstance();\n return instance.easing(easingFunction);\n }\n\n easing(easingFunction: EasingFunction): this {\n this.easingV = easingFunction;\n return this;\n }\n\n static rotate<T extends typeof ComplexAnimationBuilder>(\n this: T,\n degree: string\n ) {\n const instance = this.createInstance();\n return instance.rotate(degree);\n }\n\n rotate(degree: string): this {\n this.rotateV = degree;\n return this;\n }\n\n static springify<T extends typeof ComplexAnimationBuilder>(\n this: T,\n duration?: number\n ): ComplexAnimationBuilder {\n const instance = this.createInstance();\n return instance.springify(duration);\n }\n\n springify(duration?: number): this {\n this.durationV = duration;\n this.type = withSpring as AnimationFunction;\n return this;\n }\n\n static dampingRatio<T extends typeof ComplexAnimationBuilder>(\n this: T,\n dampingRatio: number\n ) {\n const instance = this.createInstance();\n return instance.dampingRatio(dampingRatio);\n }\n\n dampingRatio(dampingRatio: number): this {\n this.dampingRatioV = dampingRatio;\n return this;\n }\n\n static damping<T extends typeof ComplexAnimationBuilder>(\n this: T,\n damping: number\n ) {\n const instance = this.createInstance();\n return instance.damping(damping);\n }\n\n damping(damping: number): this {\n this.dampingV = damping;\n return this;\n }\n\n static mass<T extends typeof ComplexAnimationBuilder>(this: T, mass: number) {\n const instance = this.createInstance();\n return instance.mass(mass);\n }\n\n mass(mass: number): this {\n this.massV = mass;\n return this;\n }\n\n static stiffness<T extends typeof ComplexAnimationBuilder>(\n this: T,\n stiffness: number\n ) {\n const instance = this.createInstance();\n return instance.stiffness(stiffness);\n }\n\n stiffness(stiffness: number): this {\n this.stiffnessV = stiffness;\n return this;\n }\n\n static overshootClamping<T extends typeof ComplexAnimationBuilder>(\n this: T,\n overshootClamping: number\n ) {\n const instance = this.createInstance();\n return instance.overshootClamping(overshootClamping);\n }\n\n overshootClamping(overshootClamping: number): this {\n this.overshootClampingV = overshootClamping;\n return this;\n }\n\n static restDisplacementThreshold<T extends typeof ComplexAnimationBuilder>(\n this: T,\n restDisplacementThreshold: number\n ) {\n const instance = this.createInstance();\n return instance.restDisplacementThreshold(restDisplacementThreshold);\n }\n\n restDisplacementThreshold(restDisplacementThreshold: number) {\n this.restDisplacementThresholdV = restDisplacementThreshold;\n return this;\n }\n\n static restSpeedThreshold<T extends typeof ComplexAnimationBuilder>(\n this: T,\n restSpeedThreshold: number\n ) {\n const instance = this.createInstance();\n return instance.restSpeedThreshold(restSpeedThreshold);\n }\n\n restSpeedThreshold(restSpeedThreshold: number): this {\n this.restSpeedThresholdV = restSpeedThreshold;\n return this;\n }\n\n static withInitialValues<T extends typeof ComplexAnimationBuilder>(\n this: T,\n values: StyleProps\n ) {\n const instance = this.createInstance();\n return instance.withInitialValues(values);\n }\n\n withInitialValues(values: StyleProps): this {\n this.initialValues = values;\n return this;\n }\n\n getAnimationAndConfig(): LayoutAnimationAndConfig {\n const duration = this.durationV;\n const easing = this.easingV;\n const rotate = this.rotateV;\n const type = this.type ? this.type : (withTiming as AnimationFunction);\n const damping = this.dampingV;\n const dampingRatio = this.dampingRatioV;\n const mass = this.massV;\n const stiffness = this.stiffnessV;\n const overshootClamping = this.overshootClampingV;\n const restDisplacementThreshold = this.restDisplacementThresholdV;\n const restSpeedThreshold = this.restSpeedThresholdV;\n\n const animation = type;\n\n const config: BaseBuilderAnimationConfig = {};\n\n function maybeSetConfigValue<Key extends keyof BaseBuilderAnimationConfig>(\n value: BaseBuilderAnimationConfig[Key],\n variableName: Key\n ) {\n if (value) {\n config[variableName] = value;\n }\n }\n\n if (type === withTiming) {\n maybeSetConfigValue(easing, 'easing');\n }\n\n (\n [\n { variableName: 'damping', value: damping },\n { variableName: 'dampingRatio', value: dampingRatio },\n { variableName: 'mass', value: mass },\n { variableName: 'stiffness', value: stiffness },\n { variableName: 'overshootClamping', value: overshootClamping },\n {\n variableName: 'restDisplacementThreshold',\n value: restDisplacementThreshold,\n },\n { variableName: 'restSpeedThreshold', value: restSpeedThreshold },\n { variableName: 'duration', value: duration },\n { variableName: 'rotate', value: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;MAAEmB,YAAY,EAAE,cAAc;MAAE3D,KAAK,EAAEsC;IAAa,CAAC,EACrD;MAAEqB,YAAY,EAAE,MAAM;MAAE3D,KAAK,EAAE0C;IAAK,CAAC,EACrC;MAAEiB,YAAY,EAAE,WAAW;MAAE3D,KAAK,EAAE4C;IAAU,CAAC,EAC/C;MAAEe,YAAY,EAAE,mBAAmB;MAAE3D,KAAK,EAAE8C;IAAkB,CAAC,EAC/D;MACEa,YAAY,EAAE,2BAA2B;MACzC3D,KAAK,EAAEgD;IACT,CAAC,EACD;MAAEW,YAAY,EAAE,oBAAoB;MAAE3D,KAAK,EAAEkD;IAAmB,CAAC,EACjE;MAAES,YAAY,EAAE,UAAU;MAAE3D,KAAK,EAAEmC;IAAS,CAAC,EAC7C;MAAEwB,YAAY,EAAE,QAAQ;MAAE3D,KAAK,EAAE+B;IAAO,CAAC,CAC1C,CACD6B,OAAO,CAACC,IAAA;MAAA,IAAC;QAAE7D,KAAK;QAAE2D;MAAa,CAAC,GAAAE,IAAA;MAAA,OAChCH,mBAAmB,CAAC1D,KAAK,EAAE2D,YAAY,CAAC;IAAA,EACzC;IAED,OAAO,CAACH,SAAS,EAAEC,MAAM,CAAC;EAC5B;AACF;AAAC5D,eAAA,CAjNY0B,uBAAuB"}
|
|
1
|
+
{"version":3,"names":["_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","withTiming","withSpring","BaseAnimationBuilder","ComplexAnimationBuilder","constructor","arguments","easing","easingFunction","instance","createInstance","easingV","rotate","degree","rotateV","springify","duration","durationV","type","dampingRatio","dampingRatioV","damping","dampingV","mass","massV","stiffness","stiffnessV","overshootClamping","overshootClampingV","restDisplacementThreshold","restDisplacementThresholdV","restSpeedThreshold","restSpeedThresholdV","withInitialValues","values","initialValues","getAnimationAndConfig","animation","config","maybeSetConfigValue","variableName","forEach","_ref"],"sources":["ComplexAnimationBuilder.ts"],"sourcesContent":["'use strict';\nimport { withTiming, withSpring } from '../../animation';\nimport type {\n AnimationFunction,\n BaseBuilderAnimationConfig,\n LayoutAnimationAndConfig,\n} from './commonTypes';\nimport type { EasingFunction } from '../../Easing';\nimport { BaseAnimationBuilder } from './BaseAnimationBuilder';\nimport type { StyleProps } from '../../commonTypes';\n\nexport class ComplexAnimationBuilder extends BaseAnimationBuilder {\n easingV?: EasingFunction;\n rotateV?: string;\n type?: AnimationFunction;\n dampingV?: number;\n dampingRatioV?: number;\n massV?: number;\n stiffnessV?: number;\n overshootClampingV?: number;\n restDisplacementThresholdV?: number;\n restSpeedThresholdV?: number;\n initialValues?: StyleProps;\n\n static createInstance: <T extends typeof BaseAnimationBuilder>(\n this: T\n ) => InstanceType<T>;\n\n /**\n * Lets you change the easing curve of the animation. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param easingFunction - An easing function which defines the animation curve.\n */\n static easing<T extends typeof ComplexAnimationBuilder>(\n this: T,\n easingFunction: EasingFunction\n ) {\n const instance = this.createInstance();\n return instance.easing(easingFunction);\n }\n\n easing(easingFunction: EasingFunction): this {\n this.easingV = easingFunction;\n return this;\n }\n\n /**\n * Lets you rotate the element. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param degree - The rotation degree.\n */\n static rotate<T extends typeof ComplexAnimationBuilder>(\n this: T,\n degree: string\n ) {\n const instance = this.createInstance();\n return instance.rotate(degree);\n }\n\n rotate(degree: string): this {\n this.rotateV = degree;\n return this;\n }\n\n /**\n * Enables the spring-based animation configuration. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param duration - An optional duration of the spring animation (in milliseconds).\n */\n static springify<T extends typeof ComplexAnimationBuilder>(\n this: T,\n duration?: number\n ): ComplexAnimationBuilder {\n const instance = this.createInstance();\n return instance.springify(duration);\n }\n\n springify(duration?: number): this {\n this.durationV = duration;\n this.type = withSpring as AnimationFunction;\n return this;\n }\n\n /**\n * Lets you adjust the spring animation damping ratio. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param dampingRatio - How damped the spring is.\n */\n static dampingRatio<T extends typeof ComplexAnimationBuilder>(\n this: T,\n dampingRatio: number\n ) {\n const instance = this.createInstance();\n return instance.dampingRatio(dampingRatio);\n }\n\n dampingRatio(value: number): this {\n this.dampingRatioV = value;\n return this;\n }\n\n /**\n * Lets you adjust the spring animation damping. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param value - Decides how quickly a spring stops moving. Higher damping means the spring will come to rest faster.\n */\n static damping<T extends typeof ComplexAnimationBuilder>(\n this: T,\n damping: number\n ) {\n const instance = this.createInstance();\n return instance.damping(damping);\n }\n\n damping(damping: number): this {\n this.dampingV = damping;\n return this;\n }\n\n /**\n * Lets you adjust the spring animation mass. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param mass - The weight of the spring. Reducing this value makes the animation faster.\n */\n static mass<T extends typeof ComplexAnimationBuilder>(this: T, mass: number) {\n const instance = this.createInstance();\n return instance.mass(mass);\n }\n\n mass(mass: number): this {\n this.massV = mass;\n return this;\n }\n\n /**\n * Lets you adjust the stiffness of the spring animation. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param stiffness - How bouncy the spring is.\n */\n static stiffness<T extends typeof ComplexAnimationBuilder>(\n this: T,\n stiffness: number\n ) {\n const instance = this.createInstance();\n return instance.stiffness(stiffness);\n }\n\n stiffness(stiffness: number): this {\n this.stiffnessV = stiffness;\n return this;\n }\n\n /**\n * Lets you adjust overshoot clamping of the spring. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param overshootClamping - Whether a spring can bounce over the final position.\n */\n static overshootClamping<T extends typeof ComplexAnimationBuilder>(\n this: T,\n overshootClamping: number\n ) {\n const instance = this.createInstance();\n return instance.overshootClamping(overshootClamping);\n }\n\n overshootClamping(overshootClamping: number): this {\n this.overshootClampingV = overshootClamping;\n return this;\n }\n\n /**\n * Lets you adjust the rest displacement threshold of the spring animation. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param restDisplacementThreshold - The displacement below which the spring will snap to the designated position without further oscillations.\n */\n static restDisplacementThreshold<T extends typeof ComplexAnimationBuilder>(\n this: T,\n restDisplacementThreshold: number\n ) {\n const instance = this.createInstance();\n return instance.restDisplacementThreshold(restDisplacementThreshold);\n }\n\n restDisplacementThreshold(restDisplacementThreshold: number) {\n this.restDisplacementThresholdV = restDisplacementThreshold;\n return this;\n }\n\n /**\n * Lets you adjust the rest speed threshold of the spring animation. Can be chained alongside other [layout animation modifiers](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#layout-animation-modifier).\n *\n * @param restSpeedThreshold - The speed in pixels per second from which the spring will snap to the designated position without further oscillations.\n */\n static restSpeedThreshold<T extends typeof ComplexAnimationBuilder>(\n this: T,\n restSpeedThreshold: number\n ) {\n const instance = this.createInstance();\n return instance.restSpeedThreshold(restSpeedThreshold);\n }\n\n restSpeedThreshold(restSpeedThreshold: number): this {\n this.restSpeedThresholdV = restSpeedThreshold;\n return this;\n }\n\n /**\n * Lets you override the initial config of the animation\n *\n * @param values - An object containing the styles to override.\n */\n static withInitialValues<T extends typeof ComplexAnimationBuilder>(\n this: T,\n values: StyleProps\n ) {\n const instance = this.createInstance();\n return instance.withInitialValues(values);\n }\n\n withInitialValues(values: StyleProps): this {\n this.initialValues = values;\n return this;\n }\n\n getAnimationAndConfig(): LayoutAnimationAndConfig {\n const duration = this.durationV;\n const easing = this.easingV;\n const rotate = this.rotateV;\n const type = this.type ? this.type : (withTiming as AnimationFunction);\n const damping = this.dampingV;\n const dampingRatio = this.dampingRatioV;\n const mass = this.massV;\n const stiffness = this.stiffnessV;\n const overshootClamping = this.overshootClampingV;\n const restDisplacementThreshold = this.restDisplacementThresholdV;\n const restSpeedThreshold = this.restSpeedThresholdV;\n\n const animation = type;\n\n const config: BaseBuilderAnimationConfig = {};\n\n function maybeSetConfigValue<Key extends keyof BaseBuilderAnimationConfig>(\n value: BaseBuilderAnimationConfig[Key],\n variableName: Key\n ) {\n if (value) {\n config[variableName] = value;\n }\n }\n\n if (type === withTiming) {\n maybeSetConfigValue(easing, 'easing');\n }\n\n (\n [\n { variableName: 'damping', value: damping },\n { variableName: 'dampingRatio', value: dampingRatio },\n { variableName: 'mass', value: mass },\n { variableName: 'stiffness', value: stiffness },\n { variableName: 'overshootClamping', value: overshootClamping },\n {\n variableName: 'restDisplacementThreshold',\n value: restDisplacementThreshold,\n },\n { variableName: 'restSpeedThreshold', value: restSpeedThreshold },\n { variableName: 'duration', value: duration },\n { variableName: 'rotate', value: rotate },\n ] as const\n ).forEach(({ value, variableName }) =>\n maybeSetConfigValue(value, variableName)\n );\n\n return [animation, config];\n }\n}\n"],"mappings":"AAAA,YAAY;;AAAC,SAAAA,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SAAAG,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR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AAC,EAC/C;MAAEe,YAAY,EAAE,mBAAmB;MAAE3D,KAAK,EAAE8C;IAAkB,CAAC,EAC/D;MACEa,YAAY,EAAE,2BAA2B;MACzC3D,KAAK,EAAEgD;IACT,CAAC,EACD;MAAEW,YAAY,EAAE,oBAAoB;MAAE3D,KAAK,EAAEkD;IAAmB,CAAC,EACjE;MAAES,YAAY,EAAE,UAAU;MAAE3D,KAAK,EAAEmC;IAAS,CAAC,EAC7C;MAAEwB,YAAY,EAAE,QAAQ;MAAE3D,KAAK,EAAE+B;IAAO,CAAC,CAC1C,CACD6B,OAAO,CAACC,IAAA;MAAA,IAAC;QAAE7D,KAAK;QAAE2D;MAAa,CAAC,GAAAE,IAAA;MAAA,OAChCH,mBAAmB,CAAC1D,KAAK,EAAE2D,YAAY,CAAC;IAAA,EACzC;IAED,OAAO,CAACH,SAAS,EAAEC,MAAM,CAAC;EAC5B;AACF;AAAC5D,eAAA,CAxQY0B,uBAAuB"}
|
|
@@ -64,7 +64,7 @@ class InnerKeyframe {
|
|
|
64
64
|
if (key.includes('transform')) {
|
|
65
65
|
initialValues[key].forEach((transformProp, index) => {
|
|
66
66
|
Object.keys(transformProp).forEach(transformPropKey => {
|
|
67
|
-
addAnimation(index
|
|
67
|
+
addAnimation(makeKeyframeKey(index, transformPropKey));
|
|
68
68
|
});
|
|
69
69
|
});
|
|
70
70
|
} else {
|
|
@@ -121,7 +121,7 @@ class InnerKeyframe {
|
|
|
121
121
|
}
|
|
122
122
|
initialValues.transform.forEach((transformStyle, index) => {
|
|
123
123
|
Object.keys(transformStyle).forEach(transformProp => {
|
|
124
|
-
parsedKeyframes[index
|
|
124
|
+
parsedKeyframes[makeKeyframeKey(index, transformProp)] = [];
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
} else {
|
|
@@ -175,7 +175,7 @@ class InnerKeyframe {
|
|
|
175
175
|
}
|
|
176
176
|
keyframe.transform.forEach((transformStyle, index) => {
|
|
177
177
|
Object.keys(transformStyle).forEach(transformProp => {
|
|
178
|
-
addKeyPointWith(index
|
|
178
|
+
addKeyPointWith(makeKeyframeKey(index, transformProp), transformStyle[transformProp]);
|
|
179
179
|
});
|
|
180
180
|
});
|
|
181
181
|
} else {
|
|
@@ -219,6 +219,9 @@ class InnerKeyframe {
|
|
|
219
219
|
};
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
+
function makeKeyframeKey(index, transformProp) {
|
|
223
|
+
return `${index}_transform:${transformProp}`;
|
|
224
|
+
}
|
|
222
225
|
|
|
223
226
|
// TODO TYPESCRIPT This is a temporary type to get rid of .d.ts file.
|
|
224
227
|
|