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/nodes/AnimatedStyle.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import AnimatedNode from './AnimatedNode';
|
|
2
|
-
import AnimatedTransform from './AnimatedTransform';
|
|
3
|
-
import AnimatedWithInput from './AnimatedWithInput';
|
|
4
|
-
import NativeAnimatedHelper from '../NativeAnimatedHelper';
|
|
5
|
-
|
|
6
|
-
import flattenStyle from 'flattenStyle';
|
|
7
|
-
|
|
8
|
-
export default class AnimatedStyle extends AnimatedWithInput {
|
|
9
|
-
constructor(style) {
|
|
10
|
-
style = flattenStyle(style) || {};
|
|
11
|
-
if (style.transform) {
|
|
12
|
-
style = {
|
|
13
|
-
...style,
|
|
14
|
-
transform: new AnimatedTransform(style.transform),
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
super(Object.values(style));
|
|
18
|
-
this._style = style;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Recursively get values for nested styles (like iOS's shadowOffset)
|
|
22
|
-
_walkStyleAndGetValues(style) {
|
|
23
|
-
const updatedStyle = {};
|
|
24
|
-
for (const key in style) {
|
|
25
|
-
const value = style[key];
|
|
26
|
-
if (value instanceof AnimatedNode) {
|
|
27
|
-
if (!value.__isNative) {
|
|
28
|
-
// We cannot use value of natively driven nodes this way as the value we have access from
|
|
29
|
-
// JS may not be up to date.
|
|
30
|
-
updatedStyle[key] = value.__getProps();
|
|
31
|
-
}
|
|
32
|
-
} else if (value && !Array.isArray(value) && typeof value === 'object') {
|
|
33
|
-
// Support animating nested values (for example: shadowOffset.height)
|
|
34
|
-
updatedStyle[key] = this._walkStyleAndGetValues(value);
|
|
35
|
-
} else {
|
|
36
|
-
updatedStyle[key] = value;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return updatedStyle;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
__getProps() {
|
|
43
|
-
return this._walkStyleAndGetValues(this._style);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
_walkStyleAndGetAnimatedValues(style) {
|
|
47
|
-
const updatedStyle = {};
|
|
48
|
-
for (const key in style) {
|
|
49
|
-
const value = style[key];
|
|
50
|
-
if (value instanceof AnimatedNode) {
|
|
51
|
-
updatedStyle[key] = value.__getValue();
|
|
52
|
-
} else if (value && !Array.isArray(value) && typeof value === 'object') {
|
|
53
|
-
// Support animating nested values (for example: shadowOffset.height)
|
|
54
|
-
updatedStyle[key] = this._walkStyleAndGetAnimatedValues(value);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return updatedStyle;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
__onEvaluate() {
|
|
61
|
-
return this._walkStyleAndGetAnimatedValues(this._style);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
__makeNative() {
|
|
65
|
-
super.__makeNative();
|
|
66
|
-
for (const key in this._style) {
|
|
67
|
-
const value = this._style[key];
|
|
68
|
-
if (value instanceof AnimatedNode) {
|
|
69
|
-
value.__makeNative();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
__getNativeConfig() {
|
|
75
|
-
const styleConfig = {};
|
|
76
|
-
for (const styleKey in this._style) {
|
|
77
|
-
if (this._style[styleKey] instanceof AnimatedNode) {
|
|
78
|
-
styleConfig[styleKey] = this._style[styleKey].__getNativeTag();
|
|
79
|
-
}
|
|
80
|
-
// Non-animated styles are set using `setNativeProps`, no need
|
|
81
|
-
// to pass those as a part of the node config
|
|
82
|
-
}
|
|
83
|
-
NativeAnimatedHelper.validateStyles(styleConfig);
|
|
84
|
-
return {
|
|
85
|
-
type: 'style',
|
|
86
|
-
style: styleConfig,
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import AnimatedNode from './AnimatedNode';
|
|
2
|
-
|
|
3
|
-
export default class AnimatedTracking extends AnimatedNode {
|
|
4
|
-
constructor(value, parent, animationClass, animationConfig, callback) {
|
|
5
|
-
super();
|
|
6
|
-
this._value = value;
|
|
7
|
-
this._parent = parent;
|
|
8
|
-
this._animationClass = animationClass;
|
|
9
|
-
this._animationConfig = animationConfig;
|
|
10
|
-
this._callback = callback;
|
|
11
|
-
this.__attach();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
__getValue() {
|
|
15
|
-
return this._parent.__getValue();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
__attach() {
|
|
19
|
-
this._parent.__addChild(this);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
__detach() {
|
|
23
|
-
this._parent.__removeChild(this);
|
|
24
|
-
super.__detach();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
update() {
|
|
28
|
-
this._value.animate(
|
|
29
|
-
new this._animationClass({
|
|
30
|
-
...this._animationConfig,
|
|
31
|
-
toValue: this._animationConfig.toValue.__getValue(),
|
|
32
|
-
}),
|
|
33
|
-
this._callback
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import AnimatedNode from './AnimatedNode';
|
|
2
|
-
import AnimatedWithInput from './AnimatedWithInput';
|
|
3
|
-
import NativeAnimatedHelper from '../NativeAnimatedHelper';
|
|
4
|
-
|
|
5
|
-
function extractAnimatedParentNodes(transforms) {
|
|
6
|
-
const parents = [];
|
|
7
|
-
transforms.forEach(transform => {
|
|
8
|
-
const result = {};
|
|
9
|
-
for (const key in transform) {
|
|
10
|
-
const value = transform[key];
|
|
11
|
-
if (value instanceof AnimatedNode) {
|
|
12
|
-
parents.push(value);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
return parents;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default class AnimatedTransform extends AnimatedWithInput {
|
|
20
|
-
constructor(transforms) {
|
|
21
|
-
super(extractAnimatedParentNodes(transforms));
|
|
22
|
-
this._transforms = transforms;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
__makeNative() {
|
|
26
|
-
super.__makeNative();
|
|
27
|
-
this._transforms.forEach(transform => {
|
|
28
|
-
for (const key in transform) {
|
|
29
|
-
const value = transform[key];
|
|
30
|
-
if (value instanceof AnimatedNode) {
|
|
31
|
-
value.__makeNative();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
__getProps() {
|
|
38
|
-
return this._transforms.map(transform => {
|
|
39
|
-
const result = {};
|
|
40
|
-
for (const key in transform) {
|
|
41
|
-
const value = transform[key];
|
|
42
|
-
if (value instanceof AnimatedNode) {
|
|
43
|
-
result[key] = value.__getProps();
|
|
44
|
-
} else {
|
|
45
|
-
result[key] = value;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return result;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
__onEvaluate() {
|
|
53
|
-
return this._transforms.map(transform => {
|
|
54
|
-
const result = {};
|
|
55
|
-
for (const key in transform) {
|
|
56
|
-
const value = transform[key];
|
|
57
|
-
if (value instanceof AnimatedNode) {
|
|
58
|
-
result[key] = value.__getValue();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return result;
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
__getNativeConfig() {
|
|
66
|
-
const transConfigs = [];
|
|
67
|
-
|
|
68
|
-
this._transforms.forEach(transform => {
|
|
69
|
-
for (const key in transform) {
|
|
70
|
-
const value = transform[key];
|
|
71
|
-
if (value instanceof AnimatedNode) {
|
|
72
|
-
transConfigs.push({
|
|
73
|
-
type: 'animated',
|
|
74
|
-
property: key,
|
|
75
|
-
nodeTag: value.__getNativeTag(),
|
|
76
|
-
});
|
|
77
|
-
} else {
|
|
78
|
-
transConfigs.push({
|
|
79
|
-
type: 'static',
|
|
80
|
-
property: key,
|
|
81
|
-
value,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
NativeAnimatedHelper.validateTransform(transConfigs);
|
|
88
|
-
return {
|
|
89
|
-
type: 'transform',
|
|
90
|
-
transforms: transConfigs,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
package/nodes/AnimatedValue.js
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import AnimatedInterpolation from './AnimatedInterpolation';
|
|
2
|
-
import AnimatedWithInput from './AnimatedWithInput';
|
|
3
|
-
import InteractionManager from 'InteractionManager';
|
|
4
|
-
import NativeAnimatedHelper from '../NativeAnimatedHelper';
|
|
5
|
-
import { onNodeUpdated } from '../CoreAnimated';
|
|
6
|
-
|
|
7
|
-
const NativeAnimatedAPI = NativeAnimatedHelper.API;
|
|
8
|
-
|
|
9
|
-
let _uniqueId = 1;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Standard value for driving animations. One `Animated.Value` can drive
|
|
13
|
-
* multiple properties in a synchronized fashion, but can only be driven by one
|
|
14
|
-
* mechanism at a time. Using a new mechanism (e.g. starting a new animation,
|
|
15
|
-
* or calling `setValue`) will stop any previous ones.
|
|
16
|
-
*
|
|
17
|
-
* See http://facebook.github.io/react-native/docs/animatedvalue.html
|
|
18
|
-
*/
|
|
19
|
-
export default class AnimatedValue extends AnimatedWithInput {
|
|
20
|
-
constructor(value) {
|
|
21
|
-
super();
|
|
22
|
-
this._startingValue = this._value = value;
|
|
23
|
-
this._offset = 0;
|
|
24
|
-
this._animation = null;
|
|
25
|
-
this._listeners = {};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
__detach() {
|
|
29
|
-
this.stopAnimation();
|
|
30
|
-
super.__detach();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
__onEvaluate() {
|
|
34
|
-
return this._value + this._offset;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
__makeNative() {
|
|
38
|
-
super.__makeNative();
|
|
39
|
-
|
|
40
|
-
if (Object.keys(this._listeners).length) {
|
|
41
|
-
this._startListeningToNativeValueUpdates();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Directly set the value. This will stop any animations running on the value
|
|
47
|
-
* and update all the bound properties.
|
|
48
|
-
*
|
|
49
|
-
* See http://facebook.github.io/react-native/docs/animatedvalue.html#setvalue
|
|
50
|
-
*/
|
|
51
|
-
setValue(value) {
|
|
52
|
-
if (this._animation) {
|
|
53
|
-
this._animation.stop();
|
|
54
|
-
this._animation = null;
|
|
55
|
-
}
|
|
56
|
-
this._updateValue(
|
|
57
|
-
value,
|
|
58
|
-
!this.__isNative /* don't perform a flush for natively driven values */
|
|
59
|
-
);
|
|
60
|
-
if (this.__isNative) {
|
|
61
|
-
NativeAnimatedAPI.setAnimatedNodeValue(this.__getNativeTag(), value);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Sets an offset that is applied on top of whatever value is set, whether via
|
|
67
|
-
* `setValue`, an animation, or `Animated.event`. Useful for compensating
|
|
68
|
-
* things like the start of a pan gesture.
|
|
69
|
-
*
|
|
70
|
-
* See http://facebook.github.io/react-native/docs/animatedvalue.html#setoffset
|
|
71
|
-
*/
|
|
72
|
-
setOffset(offset) {
|
|
73
|
-
this._offset = offset;
|
|
74
|
-
if (this.__isNative) {
|
|
75
|
-
NativeAnimatedAPI.setAnimatedNodeOffset(this.__getNativeTag(), offset);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Merges the offset value into the base value and resets the offset to zero.
|
|
81
|
-
* The final output of the value is unchanged.
|
|
82
|
-
*
|
|
83
|
-
* See http://facebook.github.io/react-native/docs/animatedvalue.html#flattenoffset
|
|
84
|
-
*/
|
|
85
|
-
flattenOffset() {
|
|
86
|
-
this._value += this._offset;
|
|
87
|
-
this._offset = 0;
|
|
88
|
-
if (this.__isNative) {
|
|
89
|
-
NativeAnimatedAPI.flattenAnimatedNodeOffset(this.__getNativeTag());
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Sets the offset value to the base value, and resets the base value to zero.
|
|
95
|
-
* The final output of the value is unchanged.
|
|
96
|
-
*
|
|
97
|
-
* See http://facebook.github.io/react-native/docs/animatedvalue.html#extractoffset
|
|
98
|
-
*/
|
|
99
|
-
extractOffset() {
|
|
100
|
-
this._offset += this._value;
|
|
101
|
-
this._value = 0;
|
|
102
|
-
if (this.__isNative) {
|
|
103
|
-
NativeAnimatedAPI.extractAnimatedNodeOffset(this.__getNativeTag());
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Adds an asynchronous listener to the value so you can observe updates from
|
|
109
|
-
* animations. This is useful because there is no way to
|
|
110
|
-
* synchronously read the value because it might be driven natively.
|
|
111
|
-
*
|
|
112
|
-
* See http://facebook.github.io/react-native/docs/animatedvalue.html#addlistener
|
|
113
|
-
*/
|
|
114
|
-
addListener(callback) {
|
|
115
|
-
const id = String(_uniqueId++);
|
|
116
|
-
this._listeners[id] = callback;
|
|
117
|
-
if (this.__isNative) {
|
|
118
|
-
this._startListeningToNativeValueUpdates();
|
|
119
|
-
}
|
|
120
|
-
return id;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Unregister a listener. The `id` param shall match the identifier
|
|
125
|
-
* previously returned by `addListener()`.
|
|
126
|
-
*
|
|
127
|
-
* See http://facebook.github.io/react-native/docs/animatedvalue.html#removelistener
|
|
128
|
-
*/
|
|
129
|
-
removeListener(id) {
|
|
130
|
-
delete this._listeners[id];
|
|
131
|
-
if (this.__isNative && Object.keys(this._listeners).length === 0) {
|
|
132
|
-
this._stopListeningForNativeValueUpdates();
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Remove all registered listeners.
|
|
138
|
-
*
|
|
139
|
-
* See http://facebook.github.io/react-native/docs/animatedvalue.html#removealllisteners
|
|
140
|
-
*/
|
|
141
|
-
removeAllListeners() {
|
|
142
|
-
this._listeners = {};
|
|
143
|
-
if (this.__isNative) {
|
|
144
|
-
this._stopListeningForNativeValueUpdates();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
_startListeningToNativeValueUpdates() {
|
|
149
|
-
if (this.__nativeAnimatedValueListener) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
NativeAnimatedAPI.startListeningToAnimatedNodeValue(this.__getNativeTag());
|
|
154
|
-
this.__nativeAnimatedValueListener = NativeAnimatedHelper.nativeEventEmitter.addListener(
|
|
155
|
-
'onAnimatedValueUpdate',
|
|
156
|
-
data => {
|
|
157
|
-
if (data.tag !== this.__getNativeTag()) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
this._updateValue(data.value, false /* flush */);
|
|
161
|
-
}
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
_stopListeningForNativeValueUpdates() {
|
|
166
|
-
if (!this.__nativeAnimatedValueListener) {
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
this.__nativeAnimatedValueListener.remove();
|
|
171
|
-
this.__nativeAnimatedValueListener = null;
|
|
172
|
-
NativeAnimatedAPI.stopListeningToAnimatedNodeValue(this.__getNativeTag());
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Stops any running animation or tracking. `callback` is invoked with the
|
|
177
|
-
* final value after stopping the animation, which is useful for updating
|
|
178
|
-
* state to match the animation position with layout.
|
|
179
|
-
*
|
|
180
|
-
* See http://facebook.github.io/react-native/docs/animatedvalue.html#stopanimation
|
|
181
|
-
*/
|
|
182
|
-
stopAnimation(callback) {
|
|
183
|
-
this.stopTracking();
|
|
184
|
-
this._animation && this._animation.stop();
|
|
185
|
-
this._animation = null;
|
|
186
|
-
callback && callback(this.__getValue());
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Stops any animation and resets the value to its original.
|
|
191
|
-
*
|
|
192
|
-
* See http://facebook.github.io/react-native/docs/animatedvalue.html#resetanimation
|
|
193
|
-
*/
|
|
194
|
-
resetAnimation(callback) {
|
|
195
|
-
this.stopAnimation(callback);
|
|
196
|
-
this._value = this._startingValue;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Interpolates the value before updating the property, e.g. mapping 0-1 to
|
|
201
|
-
* 0-10.
|
|
202
|
-
*/
|
|
203
|
-
interpolate(config) {
|
|
204
|
-
return new AnimatedInterpolation(this, config);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Typically only used internally, but could be used by a custom Animation
|
|
209
|
-
* class.
|
|
210
|
-
*
|
|
211
|
-
* See http://facebook.github.io/react-native/docs/animatedvalue.html#animate
|
|
212
|
-
*/
|
|
213
|
-
animate(animation, callback) {
|
|
214
|
-
let handle = null;
|
|
215
|
-
if (animation.__isInteraction) {
|
|
216
|
-
handle = InteractionManager.createInteractionHandle();
|
|
217
|
-
}
|
|
218
|
-
const previousAnimation = this._animation;
|
|
219
|
-
this._animation && this._animation.stop();
|
|
220
|
-
this._animation = animation;
|
|
221
|
-
animation.start(this);
|
|
222
|
-
// this._value,
|
|
223
|
-
// value => {
|
|
224
|
-
// // Natively driven animations will never call into that callback, therefore we can always
|
|
225
|
-
// // pass flush = true to allow the updated value to propagate to native with setNativeProps
|
|
226
|
-
// this._updateValue(value, true /* flush */);
|
|
227
|
-
// },
|
|
228
|
-
// result => {
|
|
229
|
-
// this._animation = null;
|
|
230
|
-
// if (handle !== null) {
|
|
231
|
-
// InteractionManager.clearInteractionHandle(handle);
|
|
232
|
-
// }
|
|
233
|
-
// callback && callback(result);
|
|
234
|
-
// },
|
|
235
|
-
// previousAnimation,
|
|
236
|
-
// this,
|
|
237
|
-
// );
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Typically only used internally.
|
|
242
|
-
*/
|
|
243
|
-
stopTracking() {
|
|
244
|
-
this._tracking && this._tracking.__detach();
|
|
245
|
-
this._tracking = null;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Typically only used internally.
|
|
250
|
-
*/
|
|
251
|
-
track(tracking) {
|
|
252
|
-
this.stopTracking();
|
|
253
|
-
this._tracking = tracking;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
_updateValue(value, flush) {
|
|
257
|
-
this._value = value;
|
|
258
|
-
onNodeUpdated(this);
|
|
259
|
-
for (const key in this._listeners) {
|
|
260
|
-
this._listeners[key]({ value: this.__getValue() });
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
__getNativeConfig() {
|
|
265
|
-
return {
|
|
266
|
-
type: 'value',
|
|
267
|
-
value: this._value,
|
|
268
|
-
offset: this._offset,
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import AnimatedNode from './AnimatedNode';
|
|
2
|
-
|
|
3
|
-
export default class AnimatedWithInput extends AnimatedNode {
|
|
4
|
-
constructor(inputNodes) {
|
|
5
|
-
super();
|
|
6
|
-
this.__inputNodes =
|
|
7
|
-
inputNodes && inputNodes.filter(node => node instanceof AnimatedNode);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
__attach() {
|
|
11
|
-
super.__attach();
|
|
12
|
-
this.__inputNodes &&
|
|
13
|
-
this.__inputNodes.forEach(node => node.__addChild(this));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
__detach() {
|
|
17
|
-
this.__inputNodes &&
|
|
18
|
-
this.__inputNodes.forEach(node => node.__removeChild(this));
|
|
19
|
-
super.__detach();
|
|
20
|
-
}
|
|
21
|
-
}
|
package/nodes/SpringNode.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import AnimatedWithInput from './AnimatedWithInput';
|
|
2
|
-
import { proxyAnimatedObject, val } from '../utils';
|
|
3
|
-
|
|
4
|
-
const MAX_STEPS_MS = 64;
|
|
5
|
-
|
|
6
|
-
function spring(now, toValue, state, config) {
|
|
7
|
-
const lastTimeMs = state.time || now;
|
|
8
|
-
const lastPosition = state.position;
|
|
9
|
-
const lastVelocity = state.velocity;
|
|
10
|
-
|
|
11
|
-
const deltaTimeMs = Math.min(now - lastTimeMs, MAX_STEPS_MS);
|
|
12
|
-
|
|
13
|
-
const c = config.damping;
|
|
14
|
-
const m = config.mass;
|
|
15
|
-
const k = config.stiffness;
|
|
16
|
-
const v0 = -lastVelocity;
|
|
17
|
-
const x0 = toValue - lastPosition;
|
|
18
|
-
|
|
19
|
-
const zeta = c / (2 * Math.sqrt(k * m)); // damping ratio
|
|
20
|
-
const omega0 = Math.sqrt(k / m); // undamped angular frequency of the oscillator (rad/ms)
|
|
21
|
-
const omega1 = omega0 * Math.sqrt(1.0 - zeta * zeta); // exponential decay
|
|
22
|
-
|
|
23
|
-
let position = 0.0;
|
|
24
|
-
let velocity = 0.0;
|
|
25
|
-
const t = deltaTimeMs / 1000.0; // in seconds
|
|
26
|
-
// throw new Error('ddd');
|
|
27
|
-
if (zeta < 1) {
|
|
28
|
-
// Under damped
|
|
29
|
-
const envelope = Math.exp(-zeta * omega0 * t);
|
|
30
|
-
position =
|
|
31
|
-
toValue -
|
|
32
|
-
envelope *
|
|
33
|
-
((v0 + zeta * omega0 * x0) / omega1 * Math.sin(omega1 * t) +
|
|
34
|
-
x0 * Math.cos(omega1 * t));
|
|
35
|
-
// This looks crazy -- it's actually just the derivative of the
|
|
36
|
-
// oscillation function
|
|
37
|
-
velocity =
|
|
38
|
-
zeta *
|
|
39
|
-
omega0 *
|
|
40
|
-
envelope *
|
|
41
|
-
(Math.sin(omega1 * t) * (v0 + zeta * omega0 * x0) / omega1 +
|
|
42
|
-
x0 * Math.cos(omega1 * t)) -
|
|
43
|
-
envelope *
|
|
44
|
-
(Math.cos(omega1 * t) * (v0 + zeta * omega0 * x0) -
|
|
45
|
-
omega1 * x0 * Math.sin(omega1 * t));
|
|
46
|
-
} else {
|
|
47
|
-
// Critically damped
|
|
48
|
-
const envelope = Math.exp(-omega0 * t);
|
|
49
|
-
position = toValue - envelope * (x0 + (v0 + omega0 * x0) * t);
|
|
50
|
-
velocity = envelope * (v0 * (t * omega0 - 1) + t * x0 * (omega0 * omega0));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// updates
|
|
54
|
-
state.time = now;
|
|
55
|
-
state.velocity = velocity;
|
|
56
|
-
state.position = position;
|
|
57
|
-
|
|
58
|
-
// Conditions for stopping the spring animation
|
|
59
|
-
let isOvershooting = false;
|
|
60
|
-
if (config.overshootClamping && config.stiffness !== 0) {
|
|
61
|
-
if (lastPosition < toValue) {
|
|
62
|
-
isOvershooting = position > toValue;
|
|
63
|
-
} else {
|
|
64
|
-
isOvershooting = position < toValue;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
const isVelocity = Math.abs(velocity) <= config.restSpeedThreshold;
|
|
68
|
-
let isDisplacement = true;
|
|
69
|
-
if (config.stiffness !== 0) {
|
|
70
|
-
isDisplacement =
|
|
71
|
-
Math.abs(toValue - position) <= config.restDisplacementThreshold;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (isOvershooting || (isVelocity && isDisplacement)) {
|
|
75
|
-
if (config.stiffness !== 0) {
|
|
76
|
-
// Ensure that we end up with a round value
|
|
77
|
-
state.velocity = 0;
|
|
78
|
-
state.position = toValue;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
state.finished = true;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export default class SpringNode extends AnimatedWithInput {
|
|
86
|
-
_clock;
|
|
87
|
-
_state;
|
|
88
|
-
_config;
|
|
89
|
-
_toValue;
|
|
90
|
-
|
|
91
|
-
constructor(clock, toValue, state, config) {
|
|
92
|
-
super([clock]);
|
|
93
|
-
this._clock = clock;
|
|
94
|
-
this._state = proxyAnimatedObject(state);
|
|
95
|
-
this._toValue = toValue;
|
|
96
|
-
this._config = config;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
update() {
|
|
100
|
-
val(this);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
__onEvaluate() {
|
|
104
|
-
spring(val(this._clock), val(this._toValue), this._state, this._config);
|
|
105
|
-
}
|
|
106
|
-
}
|
package/nodes/TimingStep.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import AnimatedWithInput from './AnimatedWithInput';
|
|
2
|
-
import { val } from '../utils';
|
|
3
|
-
|
|
4
|
-
function timing(now, state, config, easing) {
|
|
5
|
-
const time = state.time || now;
|
|
6
|
-
const dt = now - time;
|
|
7
|
-
const frameTime = state.frameTime;
|
|
8
|
-
const position = state.position;
|
|
9
|
-
|
|
10
|
-
if (frameTime + dt >= config.duration) {
|
|
11
|
-
state.position = config.toValue;
|
|
12
|
-
state.finished = 1;
|
|
13
|
-
} else {
|
|
14
|
-
const lastProgress = easing(frameTime / config.duration);
|
|
15
|
-
const dp = easing((frameTime + dt) / config.duration) - lastProgress;
|
|
16
|
-
const remaining = config.toValue - position;
|
|
17
|
-
state.position = position + remaining * dp / (1 - lastProgress);
|
|
18
|
-
}
|
|
19
|
-
state.frameTime = frameTime + dt;
|
|
20
|
-
state.time = now;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default class TimingStep extends AnimatedWithInput {
|
|
24
|
-
_state;
|
|
25
|
-
_config;
|
|
26
|
-
_easing;
|
|
27
|
-
_clock;
|
|
28
|
-
|
|
29
|
-
constructor(clock, state, config, easing) {
|
|
30
|
-
super([clock]);
|
|
31
|
-
this._clock = clock;
|
|
32
|
-
this._state = state;
|
|
33
|
-
this._config = config;
|
|
34
|
-
this._easing = easing;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
update() {
|
|
38
|
-
val(this);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
__onEvaluate() {
|
|
42
|
-
timing(val(this._clock), this._state, this._config, this._easing);
|
|
43
|
-
}
|
|
44
|
-
}
|
package/utils.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import AnimatedBlock from './nodes/AnimatedBlock';
|
|
2
|
-
import AnimatedNode from './nodes/AnimatedNode';
|
|
3
|
-
|
|
4
|
-
export function adapt(v) {
|
|
5
|
-
return Array.isArray(v) ? new AnimatedBlock(v.map(node => adapt(node))) : v;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function val(v) {
|
|
9
|
-
return v.__getValue ? v.__getValue() : v;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function proxyAnimatedObject(target) {
|
|
13
|
-
const handler = {
|
|
14
|
-
get(target, key) {
|
|
15
|
-
return val(target[key]);
|
|
16
|
-
},
|
|
17
|
-
set(target, key, val) {
|
|
18
|
-
const value = target[key];
|
|
19
|
-
if (value instanceof AnimatedNode) {
|
|
20
|
-
return value._updateValue(val);
|
|
21
|
-
} else {
|
|
22
|
-
target[key] = val;
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
return new Proxy(target, handler);
|
|
28
|
-
}
|