react-native-worklets 0.0.1-alpha → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.cpp +71 -0
- package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.h +38 -0
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +131 -0
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +82 -0
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.cpp +72 -0
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxySpec.h +44 -0
- package/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +94 -0
- package/Common/cpp/worklets/Registries/EventHandlerRegistry.h +49 -0
- package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +8 -0
- package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +39 -0
- package/Common/cpp/worklets/SharedItems/Shareables.cpp +326 -0
- package/Common/cpp/worklets/SharedItems/Shareables.h +345 -0
- package/Common/cpp/worklets/Tools/AsyncQueue.cpp +52 -0
- package/Common/cpp/worklets/Tools/AsyncQueue.h +35 -0
- package/Common/cpp/worklets/Tools/Defs.h +10 -0
- package/Common/cpp/worklets/Tools/JSISerializer.cpp +342 -0
- package/Common/cpp/worklets/Tools/JSISerializer.h +47 -0
- package/Common/cpp/worklets/Tools/JSLogger.cpp +16 -0
- package/Common/cpp/worklets/Tools/JSLogger.h +20 -0
- package/Common/cpp/worklets/Tools/JSScheduler.cpp +10 -0
- package/Common/cpp/worklets/Tools/JSScheduler.h +29 -0
- package/Common/cpp/worklets/Tools/PlatformLogger.h +16 -0
- package/Common/cpp/worklets/Tools/SingleInstanceChecker.h +72 -0
- package/Common/cpp/worklets/Tools/ThreadSafeQueue.h +49 -0
- package/Common/cpp/worklets/Tools/UIScheduler.cpp +19 -0
- package/Common/cpp/worklets/Tools/UIScheduler.h +22 -0
- package/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +29 -0
- package/Common/cpp/worklets/Tools/WorkletEventHandler.h +41 -0
- package/Common/cpp/worklets/Tools/WorkletsJSIUtils.cpp +26 -0
- package/Common/cpp/worklets/Tools/WorkletsJSIUtils.h +199 -0
- package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +20 -0
- package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +19 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +191 -0
- package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.cpp +19 -0
- package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.h +16 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.cpp +108 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.h +127 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +183 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +90 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +179 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +22 -0
- package/LICENSE +20 -0
- package/README.md +27 -0
- package/RNWorklets.podspec +70 -0
- package/android/CMakeLists.txt +56 -0
- package/android/build.gradle +313 -0
- package/android/gradle.properties +5 -0
- package/android/proguard-rules.pro +3 -0
- package/android/spotless.gradle +9 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/worklets/CMakeLists.txt +85 -0
- package/android/src/main/cpp/worklets/android/AndroidUIScheduler.cpp +63 -0
- package/android/src/main/cpp/worklets/android/AndroidUIScheduler.h +41 -0
- package/android/src/main/cpp/worklets/android/AnimationFrameCallback.h +32 -0
- package/android/src/main/cpp/worklets/android/PlatformLogger.cpp +29 -0
- package/android/src/main/cpp/worklets/android/WorkletsModule.cpp +83 -0
- package/android/src/main/cpp/worklets/android/WorkletsModule.h +63 -0
- package/android/src/main/cpp/worklets/android/WorkletsOnLoad.cpp +13 -0
- package/android/src/main/java/com/swmansion/worklets/AndroidUIScheduler.java +60 -0
- package/android/src/main/java/com/swmansion/worklets/AnimationFrameQueue/AnimationFrameCallback.java +20 -0
- package/android/src/main/java/com/swmansion/worklets/AnimationFrameQueue/AnimationFrameQueue.java +113 -0
- package/android/src/main/java/com/swmansion/worklets/JSCallInvokerResolver.java +27 -0
- package/android/src/main/java/com/swmansion/worklets/WorkletsMessageQueueThread.java +16 -0
- package/android/src/main/java/com/swmansion/worklets/WorkletsMessageQueueThreadBase.java +72 -0
- package/android/src/main/java/com/swmansion/worklets/WorkletsModule.java +106 -0
- package/android/src/main/java/com/swmansion/worklets/WorkletsPackage.java +49 -0
- package/android/src/paper/com/swmansion/worklets/NativeWorkletsModuleSpec.java +26 -0
- package/apple/worklets/apple/AnimationFrameQueue.h +15 -0
- package/apple/worklets/apple/AnimationFrameQueue.mm +81 -0
- package/apple/worklets/apple/AssertJavaScriptQueue.h +14 -0
- package/apple/worklets/apple/AssertTurboModuleManagerQueue.h +16 -0
- package/apple/worklets/apple/IOSUIScheduler.h +14 -0
- package/apple/worklets/apple/IOSUIScheduler.mm +24 -0
- package/apple/worklets/apple/PlatformLogger.mm +31 -0
- package/apple/worklets/apple/SlowAnimations.h +8 -0
- package/apple/worklets/apple/SlowAnimations.mm +47 -0
- package/apple/worklets/apple/WorkletsDisplayLink.h +21 -0
- package/apple/worklets/apple/WorkletsMessageThread.h +16 -0
- package/apple/worklets/apple/WorkletsMessageThread.mm +32 -0
- package/apple/worklets/apple/WorkletsModule.h +10 -0
- package/apple/worklets/apple/WorkletsModule.mm +85 -0
- package/lib/module/PlatformChecker.js +35 -0
- package/lib/module/PlatformChecker.js.map +1 -0
- package/lib/module/WorkletsError.js +13 -0
- package/lib/module/WorkletsError.js.map +1 -0
- package/lib/module/WorkletsModule/JSWorklets.js +36 -0
- package/lib/module/WorkletsModule/JSWorklets.js.map +1 -0
- package/lib/module/WorkletsModule/NativeWorklets.js +39 -0
- package/lib/module/WorkletsModule/NativeWorklets.js.map +1 -0
- package/lib/module/WorkletsModule/index.js +4 -0
- package/lib/module/WorkletsModule/index.js.map +1 -0
- package/lib/module/WorkletsModule/workletsModuleInstance.js +7 -0
- package/lib/module/WorkletsModule/workletsModuleInstance.js.map +1 -0
- package/lib/module/WorkletsModule/workletsModuleInstance.web.js +5 -0
- package/lib/module/WorkletsModule/workletsModuleInstance.web.js.map +1 -0
- package/lib/module/WorkletsModule/workletsModuleProxy.js +4 -0
- package/lib/module/WorkletsModule/workletsModuleProxy.js.map +1 -0
- package/lib/module/animationFrameQueue/mockedRequestAnimationFrame.js +10 -0
- package/lib/module/animationFrameQueue/mockedRequestAnimationFrame.js.map +1 -0
- package/lib/module/animationFrameQueue/requestAnimationFrame.js +36 -0
- package/lib/module/animationFrameQueue/requestAnimationFrame.js.map +1 -0
- package/lib/module/errors.js +78 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/index.js +17 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/initializers.js +158 -0
- package/lib/module/initializers.js.map +1 -0
- package/lib/module/logger/LogBox.js +15 -0
- package/lib/module/logger/LogBox.js.map +1 -0
- package/lib/module/logger/index.js +5 -0
- package/lib/module/logger/index.js.map +1 -0
- package/lib/module/logger/logger.js +137 -0
- package/lib/module/logger/logger.js.map +1 -0
- package/lib/module/privateGlobals.d.js +8 -0
- package/lib/module/privateGlobals.d.js.map +1 -0
- package/lib/module/runtimes.js +63 -0
- package/lib/module/runtimes.js.map +1 -0
- package/lib/module/shareableMappingCache.js +39 -0
- package/lib/module/shareableMappingCache.js.map +1 -0
- package/lib/module/shareables.js +417 -0
- package/lib/module/shareables.js.map +1 -0
- package/lib/module/specs/NativeWorkletsModule.js +5 -0
- package/lib/module/specs/NativeWorkletsModule.js.map +1 -0
- package/lib/module/specs/index.js +5 -0
- package/lib/module/specs/index.js.map +1 -0
- package/lib/module/threads.js +204 -0
- package/lib/module/threads.js.map +1 -0
- package/lib/module/valueUnpacker.js +83 -0
- package/lib/module/valueUnpacker.js.map +1 -0
- package/lib/module/workletFunction.js +37 -0
- package/lib/module/workletFunction.js.map +1 -0
- package/lib/module/workletTypes.js +12 -0
- package/lib/module/workletTypes.js.map +1 -0
- package/lib/typescript/PlatformChecker.d.ts +7 -0
- package/lib/typescript/PlatformChecker.d.ts.map +1 -0
- package/lib/typescript/WorkletsError.d.ts +3 -0
- package/lib/typescript/WorkletsError.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/JSWorklets.d.ts +3 -0
- package/lib/typescript/WorkletsModule/JSWorklets.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/NativeWorklets.d.ts +5 -0
- package/lib/typescript/WorkletsModule/NativeWorklets.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/index.d.ts +3 -0
- package/lib/typescript/WorkletsModule/index.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/workletsModuleInstance.d.ts +2 -0
- package/lib/typescript/WorkletsModule/workletsModuleInstance.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/workletsModuleInstance.web.d.ts +2 -0
- package/lib/typescript/WorkletsModule/workletsModuleInstance.web.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +12 -0
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -0
- package/lib/typescript/animationFrameQueue/mockedRequestAnimationFrame.d.ts +6 -0
- package/lib/typescript/animationFrameQueue/mockedRequestAnimationFrame.d.ts.map +1 -0
- package/lib/typescript/animationFrameQueue/requestAnimationFrame.d.ts +2 -0
- package/lib/typescript/animationFrameQueue/requestAnimationFrame.d.ts.map +1 -0
- package/lib/typescript/errors.d.ts +19 -0
- package/lib/typescript/errors.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +13 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/initializers.d.ts +6 -0
- package/lib/typescript/initializers.d.ts.map +1 -0
- package/lib/typescript/logger/LogBox.d.ts +32 -0
- package/lib/typescript/logger/LogBox.d.ts.map +1 -0
- package/lib/typescript/logger/index.d.ts +3 -0
- package/lib/typescript/logger/index.d.ts.map +1 -0
- package/lib/typescript/logger/logger.d.ts +52 -0
- package/lib/typescript/logger/logger.d.ts.map +1 -0
- package/lib/typescript/runtimes.d.ts +16 -0
- package/lib/typescript/runtimes.d.ts.map +1 -0
- package/lib/typescript/shareableMappingCache.d.ts +16 -0
- package/lib/typescript/shareableMappingCache.d.ts.map +1 -0
- package/lib/typescript/shareables.d.ts +15 -0
- package/lib/typescript/shareables.d.ts.map +1 -0
- package/lib/typescript/specs/NativeWorkletsModule.d.ts +7 -0
- package/lib/typescript/specs/NativeWorkletsModule.d.ts.map +1 -0
- package/lib/typescript/specs/index.d.ts +3 -0
- package/lib/typescript/specs/index.d.ts.map +1 -0
- package/lib/typescript/threads.d.ts +49 -0
- package/lib/typescript/threads.d.ts.map +1 -0
- package/lib/typescript/valueUnpacker.d.ts +2 -0
- package/lib/typescript/valueUnpacker.d.ts.map +1 -0
- package/lib/typescript/workletFunction.d.ts +27 -0
- package/lib/typescript/workletFunction.d.ts.map +1 -0
- package/lib/typescript/workletTypes.d.ts +49 -0
- package/lib/typescript/workletTypes.d.ts.map +1 -0
- package/package.json +106 -8
- package/plugin/index.js +3 -0
- package/scripts/worklets_utils.rb +53 -0
- package/src/PlatformChecker.ts +43 -0
- package/src/WorkletsError.ts +13 -0
- package/src/WorkletsModule/JSWorklets.ts +57 -0
- package/src/WorkletsModule/NativeWorklets.ts +68 -0
- package/src/WorkletsModule/index.ts +7 -0
- package/src/WorkletsModule/workletsModuleInstance.ts +9 -0
- package/src/WorkletsModule/workletsModuleInstance.web.ts +5 -0
- package/src/WorkletsModule/workletsModuleProxy.ts +30 -0
- package/src/animationFrameQueue/mockedRequestAnimationFrame.ts +11 -0
- package/src/animationFrameQueue/requestAnimationFrame.ts +41 -0
- package/src/errors.ts +103 -0
- package/src/index.ts +42 -0
- package/src/initializers.ts +175 -0
- package/src/logger/LogBox.ts +55 -0
- package/src/logger/index.ts +3 -0
- package/src/logger/logger.ts +155 -0
- package/src/privateGlobals.d.ts +41 -0
- package/src/runtimes.ts +92 -0
- package/src/shareableMappingCache.ts +44 -0
- package/src/shareables.ts +577 -0
- package/src/specs/NativeWorkletsModule.ts +9 -0
- package/src/specs/index.ts +5 -0
- package/src/threads.ts +275 -0
- package/src/valueUnpacker.ts +110 -0
- package/src/workletFunction.ts +47 -0
- package/src/workletTypes.ts +76 -0
- package/Animated.js +0 -13
- package/AnimatedEvent.js +0 -167
- package/AnimatedImplementation.js +0 -666
- package/CoreAnimated.js +0 -43
- package/Easing.js +0 -236
- package/NativeAnimatedHelper.js +0 -226
- package/SpringConfig.js +0 -79
- package/animations/Animation.js +0 -36
- package/animations/DecayAnimation.js +0 -70
- package/animations/SpringAnimation.js +0 -125
- package/animations/TimingAnimation.js +0 -70
- package/bezier.js +0 -128
- package/createAnimatedComponent.js +0 -188
- package/nodes/AnimatedBlock.js +0 -19
- package/nodes/AnimatedClock.js +0 -76
- package/nodes/AnimatedCond.js +0 -23
- package/nodes/AnimatedDetach.js +0 -15
- package/nodes/AnimatedInterpolation.js +0 -338
- package/nodes/AnimatedNode.js +0 -97
- package/nodes/AnimatedOnChange.js +0 -28
- package/nodes/AnimatedOp.js +0 -17
- package/nodes/AnimatedProps.js +0 -154
- package/nodes/AnimatedSet.js +0 -19
- package/nodes/AnimatedStartClock.js +0 -21
- package/nodes/AnimatedStopClock.js +0 -21
- package/nodes/AnimatedStyle.js +0 -89
- package/nodes/AnimatedTracking.js +0 -36
- package/nodes/AnimatedTransform.js +0 -93
- package/nodes/AnimatedValue.js +0 -271
- package/nodes/AnimatedWithInput.js +0 -21
- package/nodes/SpringNode.js +0 -106
- package/nodes/TimingStep.js +0 -44
- package/utils.js +0 -28
package/Easing.js
DELETED
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
let ease;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The `Easing` module implements common easing functions. This module is used
|
|
5
|
-
* by [Animate.timing()](docs/animate.html#timing) to convey physically
|
|
6
|
-
* believable motion in animations.
|
|
7
|
-
*
|
|
8
|
-
* You can find a visualization of some common easing functions at
|
|
9
|
-
* http://easings.net/
|
|
10
|
-
*
|
|
11
|
-
* ### Predefined animations
|
|
12
|
-
*
|
|
13
|
-
* The `Easing` module provides several predefined animations through the
|
|
14
|
-
* following methods:
|
|
15
|
-
*
|
|
16
|
-
* - [`back`](docs/easing.html#back) provides a simple animation where the
|
|
17
|
-
* object goes slightly back before moving forward
|
|
18
|
-
* - [`bounce`](docs/easing.html#bounce) provides a bouncing animation
|
|
19
|
-
* - [`ease`](docs/easing.html#ease) provides a simple inertial animation
|
|
20
|
-
* - [`elastic`](docs/easing.html#elastic) provides a simple spring interaction
|
|
21
|
-
*
|
|
22
|
-
* ### Standard functions
|
|
23
|
-
*
|
|
24
|
-
* Three standard easing functions are provided:
|
|
25
|
-
*
|
|
26
|
-
* - [`linear`](docs/easing.html#linear)
|
|
27
|
-
* - [`quad`](docs/easing.html#quad)
|
|
28
|
-
* - [`cubic`](docs/easing.html#cubic)
|
|
29
|
-
*
|
|
30
|
-
* The [`poly`](docs/easing.html#poly) function can be used to implement
|
|
31
|
-
* quartic, quintic, and other higher power functions.
|
|
32
|
-
*
|
|
33
|
-
* ### Additional functions
|
|
34
|
-
*
|
|
35
|
-
* Additional mathematical functions are provided by the following methods:
|
|
36
|
-
*
|
|
37
|
-
* - [`bezier`](docs/easing.html#bezier) provides a cubic bezier curve
|
|
38
|
-
* - [`circle`](docs/easing.html#circle) provides a circular function
|
|
39
|
-
* - [`sin`](docs/easing.html#sin) provides a sinusoidal function
|
|
40
|
-
* - [`exp`](docs/easing.html#exp) provides an exponential function
|
|
41
|
-
*
|
|
42
|
-
* The following helpers are used to modify other easing functions.
|
|
43
|
-
*
|
|
44
|
-
* - [`in`](docs/easing.html#in) runs an easing function forwards
|
|
45
|
-
* - [`inOut`](docs/easing.html#inout) makes any easing function symmetrical
|
|
46
|
-
* - [`out`](docs/easing.html#out) runs an easing function backwards
|
|
47
|
-
*/
|
|
48
|
-
export default class Easing {
|
|
49
|
-
/**
|
|
50
|
-
* A stepping function, returns 1 for any positive value of `n`.
|
|
51
|
-
*/
|
|
52
|
-
static step0(n) {
|
|
53
|
-
return n > 0 ? 1 : 0;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* A stepping function, returns 1 if `n` is greater than or equal to 1.
|
|
58
|
-
*/
|
|
59
|
-
static step1(n) {
|
|
60
|
-
return n >= 1 ? 1 : 0;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* A linear function, `f(t) = t`. Position correlates to elapsed time one to
|
|
65
|
-
* one.
|
|
66
|
-
*
|
|
67
|
-
* http://cubic-bezier.com/#0,0,1,1
|
|
68
|
-
*/
|
|
69
|
-
static linear(t) {
|
|
70
|
-
return t;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* A simple inertial interaction, similar to an object slowly accelerating to
|
|
75
|
-
* speed.
|
|
76
|
-
*
|
|
77
|
-
* http://cubic-bezier.com/#.42,0,1,1
|
|
78
|
-
*/
|
|
79
|
-
static ease(t) {
|
|
80
|
-
if (!ease) {
|
|
81
|
-
ease = Easing.bezier(0.42, 0, 1, 1);
|
|
82
|
-
}
|
|
83
|
-
return ease(t);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* A quadratic function, `f(t) = t * t`. Position equals the square of elapsed
|
|
88
|
-
* time.
|
|
89
|
-
*
|
|
90
|
-
* http://easings.net/#easeInQuad
|
|
91
|
-
*/
|
|
92
|
-
static quad(t) {
|
|
93
|
-
return t * t;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* A cubic function, `f(t) = t * t * t`. Position equals the cube of elapsed
|
|
98
|
-
* time.
|
|
99
|
-
*
|
|
100
|
-
* http://easings.net/#easeInCubic
|
|
101
|
-
*/
|
|
102
|
-
static cubic(t) {
|
|
103
|
-
return t * t * t;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* A power function. Position is equal to the Nth power of elapsed time.
|
|
108
|
-
*
|
|
109
|
-
* n = 4: http://easings.net/#easeInQuart
|
|
110
|
-
* n = 5: http://easings.net/#easeInQuint
|
|
111
|
-
*/
|
|
112
|
-
static poly(n) {
|
|
113
|
-
return t => Math.pow(t, n);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* A sinusoidal function.
|
|
118
|
-
*
|
|
119
|
-
* http://easings.net/#easeInSine
|
|
120
|
-
*/
|
|
121
|
-
static sin(t) {
|
|
122
|
-
return 1 - Math.cos(t * Math.PI / 2);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* A circular function.
|
|
127
|
-
*
|
|
128
|
-
* http://easings.net/#easeInCirc
|
|
129
|
-
*/
|
|
130
|
-
static circle(t) {
|
|
131
|
-
return 1 - Math.sqrt(1 - t * t);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* An exponential function.
|
|
136
|
-
*
|
|
137
|
-
* http://easings.net/#easeInExpo
|
|
138
|
-
*/
|
|
139
|
-
static exp(t) {
|
|
140
|
-
return Math.pow(2, 10 * (t - 1));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* A simple elastic interaction, similar to a spring oscillating back and
|
|
145
|
-
* forth.
|
|
146
|
-
*
|
|
147
|
-
* Default bounciness is 1, which overshoots a little bit once. 0 bounciness
|
|
148
|
-
* doesn't overshoot at all, and bounciness of N > 1 will overshoot about N
|
|
149
|
-
* times.
|
|
150
|
-
*
|
|
151
|
-
* http://easings.net/#easeInElastic
|
|
152
|
-
*/
|
|
153
|
-
static elastic(bounciness = 1) {
|
|
154
|
-
const p = bounciness * Math.PI;
|
|
155
|
-
return t => 1 - Math.pow(Math.cos(t * Math.PI / 2), 3) * Math.cos(t * p);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Use with `Animated.parallel()` to create a simple effect where the object
|
|
160
|
-
* animates back slightly as the animation starts.
|
|
161
|
-
*
|
|
162
|
-
* Wolfram Plot:
|
|
163
|
-
*
|
|
164
|
-
* - http://tiny.cc/back_default (s = 1.70158, default)
|
|
165
|
-
*/
|
|
166
|
-
static back(s) {
|
|
167
|
-
if (s === undefined) {
|
|
168
|
-
s = 1.70158;
|
|
169
|
-
}
|
|
170
|
-
return t => t * t * ((s + 1) * t - s);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Provides a simple bouncing effect.
|
|
175
|
-
*
|
|
176
|
-
* http://easings.net/#easeInBounce
|
|
177
|
-
*/
|
|
178
|
-
static bounce(t) {
|
|
179
|
-
if (t < 1 / 2.75) {
|
|
180
|
-
return 7.5625 * t * t;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (t < 2 / 2.75) {
|
|
184
|
-
t -= 1.5 / 2.75;
|
|
185
|
-
return 7.5625 * t * t + 0.75;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (t < 2.5 / 2.75) {
|
|
189
|
-
t -= 2.25 / 2.75;
|
|
190
|
-
return 7.5625 * t * t + 0.9375;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
t -= 2.625 / 2.75;
|
|
194
|
-
return 7.5625 * t * t + 0.984375;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Provides a cubic bezier curve, equivalent to CSS Transitions'
|
|
199
|
-
* `transition-timing-function`.
|
|
200
|
-
*
|
|
201
|
-
* A useful tool to visualize cubic bezier curves can be found at
|
|
202
|
-
* http://cubic-bezier.com/
|
|
203
|
-
*/
|
|
204
|
-
static bezier(x1, y1, x2, y2) {
|
|
205
|
-
const _bezier = require('bezier');
|
|
206
|
-
return _bezier(x1, y1, x2, y2);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Runs an easing function forwards.
|
|
211
|
-
*/
|
|
212
|
-
static in(easing) {
|
|
213
|
-
return easing;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Runs an easing function backwards.
|
|
218
|
-
*/
|
|
219
|
-
static out(easing) {
|
|
220
|
-
return t => 1 - easing(1 - t);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Makes any easing function symmetrical. The easing function will run
|
|
225
|
-
* forwards for half of the duration, then backwards for the rest of the
|
|
226
|
-
* duration.
|
|
227
|
-
*/
|
|
228
|
-
static inOut(easing) {
|
|
229
|
-
return t => {
|
|
230
|
-
if (t < 0.5) {
|
|
231
|
-
return easing(t * 2) / 2;
|
|
232
|
-
}
|
|
233
|
-
return 1 - easing((1 - t) * 2) / 2;
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
}
|
package/NativeAnimatedHelper.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
const NativeAnimatedModule = require('NativeModules').NativeAnimatedModule;
|
|
2
|
-
const NativeEventEmitter = require('NativeEventEmitter');
|
|
3
|
-
|
|
4
|
-
const invariant = require('fbjs/lib/invariant');
|
|
5
|
-
|
|
6
|
-
let __nativeAnimatedNodeTagCount = 1; /* used for animated nodes */
|
|
7
|
-
let __nativeAnimationIdCount = 1; /* used for started animations */
|
|
8
|
-
|
|
9
|
-
let nativeEventEmitter;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Simple wrappers around NativeAnimatedModule to provide flow and autocmplete support for
|
|
13
|
-
* the native module methods
|
|
14
|
-
*/
|
|
15
|
-
const API = {
|
|
16
|
-
createAnimatedNode: function(tag, config) {
|
|
17
|
-
assertNativeAnimatedModule();
|
|
18
|
-
NativeAnimatedModule.createAnimatedNode(tag, config);
|
|
19
|
-
},
|
|
20
|
-
startListeningToAnimatedNodeValue: function(tag) {
|
|
21
|
-
assertNativeAnimatedModule();
|
|
22
|
-
NativeAnimatedModule.startListeningToAnimatedNodeValue(tag);
|
|
23
|
-
},
|
|
24
|
-
stopListeningToAnimatedNodeValue: function(tag) {
|
|
25
|
-
assertNativeAnimatedModule();
|
|
26
|
-
NativeAnimatedModule.stopListeningToAnimatedNodeValue(tag);
|
|
27
|
-
},
|
|
28
|
-
connectAnimatedNodes: function(parentTag, childTag) {
|
|
29
|
-
assertNativeAnimatedModule();
|
|
30
|
-
NativeAnimatedModule.connectAnimatedNodes(parentTag, childTag);
|
|
31
|
-
},
|
|
32
|
-
disconnectAnimatedNodes: function(parentTag, childTag) {
|
|
33
|
-
assertNativeAnimatedModule();
|
|
34
|
-
NativeAnimatedModule.disconnectAnimatedNodes(parentTag, childTag);
|
|
35
|
-
},
|
|
36
|
-
startAnimatingNode: function(animationId, nodeTag, config, endCallback) {
|
|
37
|
-
assertNativeAnimatedModule();
|
|
38
|
-
NativeAnimatedModule.startAnimatingNode(
|
|
39
|
-
animationId,
|
|
40
|
-
nodeTag,
|
|
41
|
-
config,
|
|
42
|
-
endCallback
|
|
43
|
-
);
|
|
44
|
-
},
|
|
45
|
-
stopAnimation: function(animationId) {
|
|
46
|
-
assertNativeAnimatedModule();
|
|
47
|
-
NativeAnimatedModule.stopAnimation(animationId);
|
|
48
|
-
},
|
|
49
|
-
setAnimatedNodeValue: function(nodeTag, value) {
|
|
50
|
-
assertNativeAnimatedModule();
|
|
51
|
-
NativeAnimatedModule.setAnimatedNodeValue(nodeTag, value);
|
|
52
|
-
},
|
|
53
|
-
setAnimatedNodeOffset: function(nodeTag, offset) {
|
|
54
|
-
assertNativeAnimatedModule();
|
|
55
|
-
NativeAnimatedModule.setAnimatedNodeOffset(nodeTag, offset);
|
|
56
|
-
},
|
|
57
|
-
flattenAnimatedNodeOffset: function(nodeTag) {
|
|
58
|
-
assertNativeAnimatedModule();
|
|
59
|
-
NativeAnimatedModule.flattenAnimatedNodeOffset(nodeTag);
|
|
60
|
-
},
|
|
61
|
-
extractAnimatedNodeOffset: function(nodeTag) {
|
|
62
|
-
assertNativeAnimatedModule();
|
|
63
|
-
NativeAnimatedModule.extractAnimatedNodeOffset(nodeTag);
|
|
64
|
-
},
|
|
65
|
-
connectAnimatedNodeToView: function(nodeTag, viewTag) {
|
|
66
|
-
assertNativeAnimatedModule();
|
|
67
|
-
NativeAnimatedModule.connectAnimatedNodeToView(nodeTag, viewTag);
|
|
68
|
-
},
|
|
69
|
-
disconnectAnimatedNodeFromView: function(nodeTag, viewTag) {
|
|
70
|
-
assertNativeAnimatedModule();
|
|
71
|
-
NativeAnimatedModule.disconnectAnimatedNodeFromView(nodeTag, viewTag);
|
|
72
|
-
},
|
|
73
|
-
dropAnimatedNode: function(tag) {
|
|
74
|
-
assertNativeAnimatedModule();
|
|
75
|
-
NativeAnimatedModule.dropAnimatedNode(tag);
|
|
76
|
-
},
|
|
77
|
-
addAnimatedEventToView: function(viewTag, eventName, eventMapping) {
|
|
78
|
-
assertNativeAnimatedModule();
|
|
79
|
-
NativeAnimatedModule.addAnimatedEventToView(
|
|
80
|
-
viewTag,
|
|
81
|
-
eventName,
|
|
82
|
-
eventMapping
|
|
83
|
-
);
|
|
84
|
-
},
|
|
85
|
-
removeAnimatedEventFromView(viewTag, eventName, animatedNodeTag) {
|
|
86
|
-
assertNativeAnimatedModule();
|
|
87
|
-
NativeAnimatedModule.removeAnimatedEventFromView(
|
|
88
|
-
viewTag,
|
|
89
|
-
eventName,
|
|
90
|
-
animatedNodeTag
|
|
91
|
-
);
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Styles allowed by the native animated implementation.
|
|
97
|
-
*
|
|
98
|
-
* In general native animated implementation should support any numeric property that doesn't need
|
|
99
|
-
* to be updated through the shadow view hierarchy (all non-layout properties).
|
|
100
|
-
*/
|
|
101
|
-
const STYLES_WHITELIST = {
|
|
102
|
-
opacity: true,
|
|
103
|
-
transform: true,
|
|
104
|
-
/* ios styles */
|
|
105
|
-
shadowOpacity: true,
|
|
106
|
-
shadowRadius: true,
|
|
107
|
-
/* legacy android transform properties */
|
|
108
|
-
scaleX: true,
|
|
109
|
-
scaleY: true,
|
|
110
|
-
translateX: true,
|
|
111
|
-
translateY: true,
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const TRANSFORM_WHITELIST = {
|
|
115
|
-
translateX: true,
|
|
116
|
-
translateY: true,
|
|
117
|
-
scale: true,
|
|
118
|
-
scaleX: true,
|
|
119
|
-
scaleY: true,
|
|
120
|
-
rotate: true,
|
|
121
|
-
rotateX: true,
|
|
122
|
-
rotateY: true,
|
|
123
|
-
perspective: true,
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const SUPPORTED_INTERPOLATION_PARAMS = {
|
|
127
|
-
inputRange: true,
|
|
128
|
-
outputRange: true,
|
|
129
|
-
extrapolate: true,
|
|
130
|
-
extrapolateRight: true,
|
|
131
|
-
extrapolateLeft: true,
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
function addWhitelistedStyleProp(prop) {
|
|
135
|
-
STYLES_WHITELIST[prop] = true;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function addWhitelistedTransformProp(prop) {
|
|
139
|
-
TRANSFORM_WHITELIST[prop] = true;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function addWhitelistedInterpolationParam(param) {
|
|
143
|
-
SUPPORTED_INTERPOLATION_PARAMS[param] = true;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function validateTransform(configs) {
|
|
147
|
-
configs.forEach(config => {
|
|
148
|
-
if (!TRANSFORM_WHITELIST.hasOwnProperty(config.property)) {
|
|
149
|
-
throw new Error(
|
|
150
|
-
`Property '${config.property}' is not supported by native animated module`
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function validateStyles(styles) {
|
|
157
|
-
for (var key in styles) {
|
|
158
|
-
if (!STYLES_WHITELIST.hasOwnProperty(key)) {
|
|
159
|
-
throw new Error(
|
|
160
|
-
`Style property '${key}' is not supported by native animated module`
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function validateInterpolation(config) {
|
|
167
|
-
for (var key in config) {
|
|
168
|
-
if (!SUPPORTED_INTERPOLATION_PARAMS.hasOwnProperty(key)) {
|
|
169
|
-
throw new Error(
|
|
170
|
-
`Interpolation property '${key}' is not supported by native animated module`
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function generateNewNodeTag() {
|
|
177
|
-
return __nativeAnimatedNodeTagCount++;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function generateNewAnimationId() {
|
|
181
|
-
return __nativeAnimationIdCount++;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
function assertNativeAnimatedModule() {
|
|
185
|
-
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
let _warnedMissingNativeAnimated = false;
|
|
189
|
-
|
|
190
|
-
function shouldUseNativeDriver(config) {
|
|
191
|
-
if (config.useNativeDriver && !NativeAnimatedModule) {
|
|
192
|
-
if (!_warnedMissingNativeAnimated) {
|
|
193
|
-
console.warn(
|
|
194
|
-
'Animated: `useNativeDriver` is not supported because the native ' +
|
|
195
|
-
'animated module is missing. Falling back to JS-based animation. To ' +
|
|
196
|
-
'resolve this, add `RCTAnimation` module to this app, or remove ' +
|
|
197
|
-
'`useNativeDriver`. ' +
|
|
198
|
-
'More info: https://github.com/facebook/react-native/issues/11094#issuecomment-263240420'
|
|
199
|
-
);
|
|
200
|
-
_warnedMissingNativeAnimated = true;
|
|
201
|
-
}
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return config.useNativeDriver || false;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
module.exports = {
|
|
209
|
-
API,
|
|
210
|
-
addWhitelistedStyleProp,
|
|
211
|
-
addWhitelistedTransformProp,
|
|
212
|
-
addWhitelistedInterpolationParam,
|
|
213
|
-
validateStyles,
|
|
214
|
-
validateTransform,
|
|
215
|
-
validateInterpolation,
|
|
216
|
-
generateNewNodeTag,
|
|
217
|
-
generateNewAnimationId,
|
|
218
|
-
assertNativeAnimatedModule,
|
|
219
|
-
shouldUseNativeDriver,
|
|
220
|
-
get nativeEventEmitter() {
|
|
221
|
-
if (!nativeEventEmitter) {
|
|
222
|
-
nativeEventEmitter = new NativeEventEmitter(NativeAnimatedModule);
|
|
223
|
-
}
|
|
224
|
-
return nativeEventEmitter;
|
|
225
|
-
},
|
|
226
|
-
};
|
package/SpringConfig.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
function stiffnessFromOrigamiValue(oValue) {
|
|
2
|
-
return (oValue - 30) * 3.62 + 194;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
function dampingFromOrigamiValue(oValue) {
|
|
6
|
-
return (oValue - 8) * 3 + 25;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function fromOrigamiTensionAndFriction(tension, friction) {
|
|
10
|
-
return {
|
|
11
|
-
stiffness: stiffnessFromOrigamiValue(tension),
|
|
12
|
-
damping: dampingFromOrigamiValue(friction),
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function fromBouncinessAndSpeed(bounciness, speed) {
|
|
17
|
-
function normalize(value, startValue, endValue) {
|
|
18
|
-
return (value - startValue) / (endValue - startValue);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function projectNormal(n, start, end) {
|
|
22
|
-
return start + n * (end - start);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function linearInterpolation(t, start, end) {
|
|
26
|
-
return t * end + (1 - t) * start;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function quadraticOutInterpolation(t, start, end) {
|
|
30
|
-
return linearInterpolation(2 * t - t * t, start, end);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function b3Friction1(x) {
|
|
34
|
-
return 0.0007 * Math.pow(x, 3) - 0.031 * Math.pow(x, 2) + 0.64 * x + 1.28;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function b3Friction2(x) {
|
|
38
|
-
return 0.000044 * Math.pow(x, 3) - 0.006 * Math.pow(x, 2) + 0.36 * x + 2;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function b3Friction3(x) {
|
|
42
|
-
return (
|
|
43
|
-
0.00000045 * Math.pow(x, 3) -
|
|
44
|
-
0.000332 * Math.pow(x, 2) +
|
|
45
|
-
0.1078 * x +
|
|
46
|
-
5.84
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function b3Nobounce(tension) {
|
|
51
|
-
if (tension <= 18) {
|
|
52
|
-
return b3Friction1(tension);
|
|
53
|
-
} else if (tension > 18 && tension <= 44) {
|
|
54
|
-
return b3Friction2(tension);
|
|
55
|
-
} else {
|
|
56
|
-
return b3Friction3(tension);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
var b = normalize(bounciness / 1.7, 0, 20);
|
|
61
|
-
b = projectNormal(b, 0, 0.8);
|
|
62
|
-
var s = normalize(speed / 1.7, 0, 20);
|
|
63
|
-
var bouncyTension = projectNormal(s, 0.5, 200);
|
|
64
|
-
var bouncyFriction = quadraticOutInterpolation(
|
|
65
|
-
b,
|
|
66
|
-
b3Nobounce(bouncyTension),
|
|
67
|
-
0.01
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
stiffness: stiffnessFromOrigamiValue(bouncyTension),
|
|
72
|
-
damping: dampingFromOrigamiValue(bouncyFriction),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
module.exports = {
|
|
77
|
-
fromOrigamiTensionAndFriction,
|
|
78
|
-
fromBouncinessAndSpeed,
|
|
79
|
-
};
|
package/animations/Animation.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import NativeAnimatedHelper from 'NativeAnimatedHelper';
|
|
2
|
-
|
|
3
|
-
// Important note: start() and stop() will only be called at most once.
|
|
4
|
-
// Once an animation has been stopped or finished its course, it will
|
|
5
|
-
// not be reused.
|
|
6
|
-
class Animation {
|
|
7
|
-
start(fromValue, onUpdate, onEnd, previousAnimation, animatedValue) {}
|
|
8
|
-
stop() {
|
|
9
|
-
if (this.__nativeId) {
|
|
10
|
-
NativeAnimatedHelper.API.stopAnimation(this.__nativeId);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
__getNativeAnimationConfig() {
|
|
14
|
-
// Subclasses that have corresponding animation implementation done in native
|
|
15
|
-
// should override this method
|
|
16
|
-
throw new Error('This animation type cannot be offloaded to native');
|
|
17
|
-
}
|
|
18
|
-
// Helper function for subclasses to make sure onEnd is only called once.
|
|
19
|
-
__debouncedOnEnd(result) {
|
|
20
|
-
const onEnd = this.__onEnd;
|
|
21
|
-
this.__onEnd = null;
|
|
22
|
-
onEnd && onEnd(result);
|
|
23
|
-
}
|
|
24
|
-
__startNativeAnimation(animatedValue) {
|
|
25
|
-
animatedValue.__makeNative();
|
|
26
|
-
this.__nativeId = NativeAnimatedHelper.generateNewAnimationId();
|
|
27
|
-
NativeAnimatedHelper.API.startAnimatingNode(
|
|
28
|
-
this.__nativeId,
|
|
29
|
-
animatedValue.__getNativeTag(),
|
|
30
|
-
this.__getNativeAnimationConfig(),
|
|
31
|
-
this.__debouncedOnEnd.bind(this)
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export default Animation;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import Animation from './Animation';
|
|
2
|
-
|
|
3
|
-
import { shouldUseNativeDriver } from '../NativeAnimatedHelper';
|
|
4
|
-
|
|
5
|
-
class DecayAnimation extends Animation {
|
|
6
|
-
constructor(config) {
|
|
7
|
-
super();
|
|
8
|
-
this._deceleration =
|
|
9
|
-
config.deceleration !== undefined ? config.deceleration : 0.998;
|
|
10
|
-
this._velocity = config.velocity;
|
|
11
|
-
this._useNativeDriver = shouldUseNativeDriver(config);
|
|
12
|
-
this.__isInteraction =
|
|
13
|
-
config.isInteraction !== undefined ? config.isInteraction : true;
|
|
14
|
-
this.__iterations = config.iterations !== undefined ? config.iterations : 1;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
__getNativeAnimationConfig() {
|
|
18
|
-
return {
|
|
19
|
-
type: 'decay',
|
|
20
|
-
deceleration: this._deceleration,
|
|
21
|
-
velocity: this._velocity,
|
|
22
|
-
iterations: this.__iterations,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
start(fromValue, onUpdate, onEnd, previousAnimation, animatedValue) {
|
|
27
|
-
this.__active = true;
|
|
28
|
-
this._lastValue = fromValue;
|
|
29
|
-
this._fromValue = fromValue;
|
|
30
|
-
this._onUpdate = onUpdate;
|
|
31
|
-
this.__onEnd = onEnd;
|
|
32
|
-
this._startTime = Date.now();
|
|
33
|
-
if (this._useNativeDriver) {
|
|
34
|
-
this.__startNativeAnimation(animatedValue);
|
|
35
|
-
} else {
|
|
36
|
-
this._animationFrame = requestAnimationFrame(this.onUpdate.bind(this));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
onUpdate() {
|
|
41
|
-
const now = Date.now();
|
|
42
|
-
|
|
43
|
-
const value =
|
|
44
|
-
this._fromValue +
|
|
45
|
-
this._velocity /
|
|
46
|
-
(1 - this._deceleration) *
|
|
47
|
-
(1 - Math.exp(-(1 - this._deceleration) * (now - this._startTime)));
|
|
48
|
-
|
|
49
|
-
this._onUpdate(value);
|
|
50
|
-
|
|
51
|
-
if (Math.abs(this._lastValue - value) < 0.1) {
|
|
52
|
-
this.__debouncedOnEnd({ finished: true });
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
this._lastValue = value;
|
|
57
|
-
if (this.__active) {
|
|
58
|
-
this._animationFrame = requestAnimationFrame(this.onUpdate.bind(this));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
stop() {
|
|
63
|
-
super.stop();
|
|
64
|
-
this.__active = false;
|
|
65
|
-
global.cancelAnimationFrame(this._animationFrame);
|
|
66
|
-
this.__debouncedOnEnd({ finished: false });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default DecayAnimation;
|