@hanzogui/animations-reanimated 3.0.5 → 4.3.1
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/dist/cjs/createAnimations.cjs +484 -334
- package/dist/cjs/createAnimations.native.js +568 -409
- package/dist/cjs/createAnimations.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/createAnimations.mjs +456 -308
- package/dist/esm/createAnimations.mjs.map +1 -1
- package/dist/esm/createAnimations.native.js +540 -383
- package/dist/esm/createAnimations.native.js.map +1 -1
- package/package.json +5 -5
- package/src/createAnimations.tsx +172 -124
- package/types/createAnimations.d.ts.map +2 -2
|
@@ -1,188 +1,218 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { getEffectiveAnimation, normalizeTransition } from "@hanzogui/animation-helpers";
|
|
3
3
|
import { getSplitStyles, hooks, isWeb, Text, useComposedRefs, useEvent, useIsomorphicLayoutEffect, useThemeWithState, View } from "@hanzogui/core";
|
|
4
4
|
import { ResetPresence, usePresence } from "@hanzogui/use-presence";
|
|
5
5
|
import React, { forwardRef, useMemo, useRef } from "react";
|
|
6
|
-
import Animated_, { cancelAnimation, runOnJS, useAnimatedReaction, useAnimatedStyle,
|
|
6
|
+
import Animated_, { cancelAnimation, runOnJS, runOnUI, useAnimatedReaction, useAnimatedStyle, useSharedValue, withDelay, withSpring, withTiming } from "react-native-reanimated";
|
|
7
7
|
function _type_of(obj) {
|
|
8
8
|
"@swc/helpers - typeof";
|
|
9
9
|
|
|
10
|
-
return obj && typeof Symbol
|
|
10
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
11
11
|
}
|
|
12
12
|
var getDefaultExport = function (module) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
var mod = module;
|
|
14
|
+
if (mod.__esModule || mod[Symbol.toStringTag] === "Module") {
|
|
15
|
+
return mod.default || mod;
|
|
16
|
+
}
|
|
17
|
+
return mod;
|
|
18
|
+
};
|
|
19
|
+
var Animated = getDefaultExport(Animated_);
|
|
20
|
+
var resolveDynamicValue = function (value, isDark) {
|
|
21
|
+
if (value !== null && (typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && "dynamic" in value && _type_of(value.dynamic) === "object") {
|
|
22
|
+
var dynamic = value.dynamic;
|
|
23
|
+
return isDark ? dynamic.dark : dynamic.light;
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
};
|
|
27
|
+
var applyAnimation = function (targetValue, config, callback) {
|
|
28
|
+
"worklet";
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
30
|
+
var delay = config.delay;
|
|
31
|
+
var animatedValue;
|
|
32
|
+
if (config.type === "timing") {
|
|
33
|
+
animatedValue = withTiming(targetValue, config, callback);
|
|
34
|
+
} else {
|
|
35
|
+
animatedValue = withSpring(targetValue, config, callback);
|
|
36
|
+
}
|
|
37
|
+
if (delay && delay > 0) {
|
|
38
|
+
animatedValue = withDelay(delay, animatedValue);
|
|
39
|
+
}
|
|
40
|
+
return animatedValue;
|
|
41
|
+
};
|
|
42
|
+
var ANIMATABLE_PROPERTIES = {
|
|
43
|
+
// Transform
|
|
44
|
+
transform: true,
|
|
45
|
+
// Opacity
|
|
46
|
+
opacity: true,
|
|
47
|
+
// Dimensions
|
|
48
|
+
height: true,
|
|
49
|
+
width: true,
|
|
50
|
+
minWidth: true,
|
|
51
|
+
minHeight: true,
|
|
52
|
+
maxWidth: true,
|
|
53
|
+
maxHeight: true,
|
|
54
|
+
// Background
|
|
55
|
+
backgroundColor: true,
|
|
56
|
+
// Border colors
|
|
57
|
+
borderColor: true,
|
|
58
|
+
borderLeftColor: true,
|
|
59
|
+
borderRightColor: true,
|
|
60
|
+
borderTopColor: true,
|
|
61
|
+
borderBottomColor: true,
|
|
62
|
+
// Border radius
|
|
63
|
+
borderRadius: true,
|
|
64
|
+
borderTopLeftRadius: true,
|
|
65
|
+
borderTopRightRadius: true,
|
|
66
|
+
borderBottomLeftRadius: true,
|
|
67
|
+
borderBottomRightRadius: true,
|
|
68
|
+
// Border width
|
|
69
|
+
borderWidth: true,
|
|
70
|
+
borderLeftWidth: true,
|
|
71
|
+
borderRightWidth: true,
|
|
72
|
+
borderTopWidth: true,
|
|
73
|
+
borderBottomWidth: true,
|
|
74
|
+
// Text
|
|
75
|
+
color: true,
|
|
76
|
+
fontSize: true,
|
|
77
|
+
fontWeight: true,
|
|
78
|
+
lineHeight: true,
|
|
79
|
+
letterSpacing: true,
|
|
80
|
+
// Position
|
|
81
|
+
left: true,
|
|
82
|
+
right: true,
|
|
83
|
+
top: true,
|
|
84
|
+
bottom: true,
|
|
85
|
+
// Margin
|
|
86
|
+
margin: true,
|
|
87
|
+
marginTop: true,
|
|
88
|
+
marginBottom: true,
|
|
89
|
+
marginLeft: true,
|
|
90
|
+
marginRight: true,
|
|
91
|
+
marginHorizontal: true,
|
|
92
|
+
marginVertical: true,
|
|
93
|
+
// Padding
|
|
94
|
+
padding: true,
|
|
95
|
+
paddingTop: true,
|
|
96
|
+
paddingBottom: true,
|
|
97
|
+
paddingLeft: true,
|
|
98
|
+
paddingRight: true,
|
|
99
|
+
paddingHorizontal: true,
|
|
100
|
+
paddingVertical: true,
|
|
101
|
+
// Flex/Gap
|
|
102
|
+
gap: true,
|
|
103
|
+
rowGap: true,
|
|
104
|
+
columnGap: true,
|
|
105
|
+
flex: true,
|
|
106
|
+
flexGrow: true,
|
|
107
|
+
flexShrink: true
|
|
108
|
+
};
|
|
109
|
+
var canAnimateProperty = function (key, value, animateOnly) {
|
|
110
|
+
if (!ANIMATABLE_PROPERTIES[key]) return false;
|
|
111
|
+
if (value === "auto") return false;
|
|
112
|
+
if (typeof value === "string" && value.startsWith("calc")) return false;
|
|
113
|
+
if (animateOnly && !animateOnly.includes(key)) return false;
|
|
114
|
+
return true;
|
|
115
|
+
};
|
|
101
116
|
function createWebAnimatedComponent(defaultTag) {
|
|
102
|
-
var isText = defaultTag === "span"
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
return Component
|
|
117
|
+
var isText = defaultTag === "span";
|
|
118
|
+
var Component = Animated.createAnimatedComponent(/* @__PURE__ */forwardRef(function (propsIn, ref) {
|
|
119
|
+
var _hooks_usePropsTransform;
|
|
120
|
+
var {
|
|
121
|
+
forwardedRef,
|
|
122
|
+
render = defaultTag,
|
|
123
|
+
...rest
|
|
124
|
+
} = propsIn;
|
|
125
|
+
var hostRef = useRef(null);
|
|
126
|
+
var composedRefs = useComposedRefs(forwardedRef, ref, hostRef);
|
|
127
|
+
var stateRef = useRef({
|
|
128
|
+
get host() {
|
|
129
|
+
return hostRef.current;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
var [, themeState] = useThemeWithState({});
|
|
133
|
+
var _themeState_theme, _themeState_name;
|
|
134
|
+
var result = getSplitStyles(rest, isText ? Text.staticConfig : View.staticConfig, (_themeState_theme = themeState === null || themeState === void 0 ? void 0 : themeState.theme) !== null && _themeState_theme !== void 0 ? _themeState_theme : {}, (_themeState_name = themeState === null || themeState === void 0 ? void 0 : themeState.name) !== null && _themeState_name !== void 0 ? _themeState_name : "", {
|
|
135
|
+
unmounted: false
|
|
136
|
+
}, {
|
|
137
|
+
isAnimated: false,
|
|
138
|
+
noClass: true
|
|
139
|
+
});
|
|
140
|
+
var _result_viewProps;
|
|
141
|
+
var viewProps = (_result_viewProps = result === null || result === void 0 ? void 0 : result.viewProps) !== null && _result_viewProps !== void 0 ? _result_viewProps : {};
|
|
142
|
+
var Element = render;
|
|
143
|
+
var transformedProps = (_hooks_usePropsTransform = hooks.usePropsTransform) === null || _hooks_usePropsTransform === void 0 ? void 0 : _hooks_usePropsTransform.call(hooks, render, viewProps, stateRef, false);
|
|
144
|
+
return /* @__PURE__ */_jsx(Element, {
|
|
145
|
+
...transformedProps,
|
|
146
|
+
ref: composedRefs
|
|
147
|
+
});
|
|
148
|
+
}));
|
|
149
|
+
Component.acceptRenderProp = true;
|
|
150
|
+
return Component;
|
|
136
151
|
}
|
|
137
|
-
var AnimatedView = createWebAnimatedComponent("div")
|
|
138
|
-
|
|
152
|
+
var AnimatedView = createWebAnimatedComponent("div");
|
|
153
|
+
var AnimatedText = createWebAnimatedComponent("span");
|
|
139
154
|
function buildTransitionConfig(transition, animations, animationState, styleKeys) {
|
|
140
|
-
var normalized = normalizeTransition(transition)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
155
|
+
var normalized = normalizeTransition(transition);
|
|
156
|
+
var effectiveKey = getEffectiveAnimation(normalized, animationState);
|
|
157
|
+
var _animations_effectiveKey;
|
|
158
|
+
var base = effectiveKey ? (_animations_effectiveKey = animations[effectiveKey]) !== null && _animations_effectiveKey !== void 0 ? _animations_effectiveKey : {
|
|
159
|
+
type: "spring"
|
|
160
|
+
} : {
|
|
161
|
+
type: "spring"
|
|
162
|
+
};
|
|
163
|
+
if (normalized.delay) {
|
|
164
|
+
base = {
|
|
165
|
+
...base,
|
|
166
|
+
delay: normalized.delay
|
|
147
167
|
};
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
168
|
+
}
|
|
169
|
+
if (normalized.config) {
|
|
170
|
+
base = {
|
|
171
|
+
...base,
|
|
172
|
+
...normalized.config
|
|
173
|
+
};
|
|
174
|
+
if (base.type !== "timing" && normalized.config.duration !== void 0 && normalized.config.damping === void 0 && normalized.config.stiffness === void 0 && normalized.config.mass === void 0) {
|
|
175
|
+
base = {
|
|
176
|
+
...base,
|
|
177
|
+
type: "timing"
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
var propertyConfigs = {};
|
|
182
|
+
var _iteratorNormalCompletion = true,
|
|
183
|
+
_didIteratorError = false,
|
|
161
184
|
_iteratorError = void 0;
|
|
162
185
|
try {
|
|
163
|
-
for (var _iterator = styleKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion =
|
|
164
|
-
var key = _step.value
|
|
165
|
-
|
|
166
|
-
if (typeof propAnimation
|
|
186
|
+
for (var _iterator = styleKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
187
|
+
var key = _step.value;
|
|
188
|
+
var propAnimation = normalized.properties[key];
|
|
189
|
+
if (typeof propAnimation === "string") {
|
|
167
190
|
var _animations_propAnimation;
|
|
168
191
|
propertyConfigs[key] = (_animations_propAnimation = animations[propAnimation]) !== null && _animations_propAnimation !== void 0 ? _animations_propAnimation : base;
|
|
169
|
-
} else if (propAnimation && (typeof propAnimation
|
|
170
|
-
var configType = propAnimation.type
|
|
171
|
-
|
|
172
|
-
|
|
192
|
+
} else if (propAnimation && (typeof propAnimation === "undefined" ? "undefined" : _type_of(propAnimation)) === "object") {
|
|
193
|
+
var configType = propAnimation.type;
|
|
194
|
+
var _animations_configType;
|
|
195
|
+
var baseForProp = configType ? (_animations_configType = animations[configType]) !== null && _animations_configType !== void 0 ? _animations_configType : base : base;
|
|
173
196
|
propertyConfigs[key] = {
|
|
174
197
|
...baseForProp,
|
|
175
198
|
...propAnimation
|
|
176
199
|
};
|
|
177
|
-
} else
|
|
200
|
+
} else {
|
|
201
|
+
propertyConfigs[key] = base;
|
|
202
|
+
}
|
|
178
203
|
}
|
|
179
204
|
} catch (err) {
|
|
180
|
-
_didIteratorError =
|
|
205
|
+
_didIteratorError = true;
|
|
206
|
+
_iteratorError = err;
|
|
181
207
|
} finally {
|
|
182
208
|
try {
|
|
183
|
-
!_iteratorNormalCompletion && _iterator.return != null
|
|
209
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
210
|
+
_iterator.return();
|
|
211
|
+
}
|
|
184
212
|
} finally {
|
|
185
|
-
if (_didIteratorError)
|
|
213
|
+
if (_didIteratorError) {
|
|
214
|
+
throw _iteratorError;
|
|
215
|
+
}
|
|
186
216
|
}
|
|
187
217
|
}
|
|
188
218
|
return {
|
|
@@ -193,21 +223,28 @@ function buildTransitionConfig(transition, animations, animationState, styleKeys
|
|
|
193
223
|
function getStyleKeys(style) {
|
|
194
224
|
var keys = new Set(Object.keys(style));
|
|
195
225
|
if (style.transform && Array.isArray(style.transform)) {
|
|
196
|
-
var _iteratorNormalCompletion =
|
|
197
|
-
_didIteratorError =
|
|
226
|
+
var _iteratorNormalCompletion = true,
|
|
227
|
+
_didIteratorError = false,
|
|
198
228
|
_iteratorError = void 0;
|
|
199
229
|
try {
|
|
200
|
-
for (var _iterator = style.transform[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion =
|
|
230
|
+
for (var _iterator = style.transform[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
201
231
|
var t = _step.value;
|
|
202
|
-
t && (typeof t
|
|
232
|
+
if (t && (typeof t === "undefined" ? "undefined" : _type_of(t)) === "object") {
|
|
233
|
+
keys.add(Object.keys(t)[0]);
|
|
234
|
+
}
|
|
203
235
|
}
|
|
204
236
|
} catch (err) {
|
|
205
|
-
_didIteratorError =
|
|
237
|
+
_didIteratorError = true;
|
|
238
|
+
_iteratorError = err;
|
|
206
239
|
} finally {
|
|
207
240
|
try {
|
|
208
|
-
!_iteratorNormalCompletion && _iterator.return != null
|
|
241
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
242
|
+
_iterator.return();
|
|
243
|
+
}
|
|
209
244
|
} finally {
|
|
210
|
-
if (_didIteratorError)
|
|
245
|
+
if (_didIteratorError) {
|
|
246
|
+
throw _iteratorError;
|
|
247
|
+
}
|
|
211
248
|
}
|
|
212
249
|
}
|
|
213
250
|
}
|
|
@@ -215,18 +252,20 @@ function getStyleKeys(style) {
|
|
|
215
252
|
}
|
|
216
253
|
function createAnimations(animationsConfig) {
|
|
217
254
|
var animations = {};
|
|
218
|
-
for (var key in animationsConfig)
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
255
|
+
for (var key in animationsConfig) {
|
|
256
|
+
animations[key] = {
|
|
257
|
+
type: "spring",
|
|
258
|
+
...animationsConfig[key]
|
|
259
|
+
};
|
|
260
|
+
}
|
|
222
261
|
return {
|
|
223
|
-
needsCustomComponent:
|
|
262
|
+
needsCustomComponent: true,
|
|
224
263
|
View: isWeb ? AnimatedView : Animated.View,
|
|
225
264
|
Text: isWeb ? AnimatedText : Animated.Text,
|
|
226
|
-
isReactNative:
|
|
265
|
+
isReactNative: true,
|
|
227
266
|
inputStyle: "value",
|
|
228
267
|
outputStyle: "inline",
|
|
229
|
-
avoidReRenders:
|
|
268
|
+
avoidReRenders: true,
|
|
230
269
|
animations,
|
|
231
270
|
usePresence,
|
|
232
271
|
ResetPresence,
|
|
@@ -248,22 +287,31 @@ function createAnimations(animationsConfig) {
|
|
|
248
287
|
return sharedValue.value;
|
|
249
288
|
},
|
|
250
289
|
setValue(next) {
|
|
251
|
-
"worklet";
|
|
252
|
-
|
|
253
290
|
var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
254
291
|
type: "spring"
|
|
255
292
|
},
|
|
256
|
-
onFinish = arguments.length > 2 ? arguments[2] : void 0
|
|
257
|
-
|
|
293
|
+
onFinish = arguments.length > 2 ? arguments[2] : void 0;
|
|
294
|
+
if (config.type === "direct") {
|
|
295
|
+
sharedValue.value = next;
|
|
296
|
+
onFinish === null || onFinish === void 0 ? void 0 : onFinish();
|
|
297
|
+
} else {
|
|
298
|
+
var cb = onFinish ? function () {
|
|
258
299
|
"worklet";
|
|
259
300
|
|
|
260
301
|
runOnJS(onFinish)();
|
|
261
302
|
} : void 0;
|
|
262
|
-
|
|
303
|
+
if (isWeb) {
|
|
304
|
+
sharedValue.value = config.type === "spring" ? withSpring(next, config, cb) : withTiming(next, config, cb);
|
|
305
|
+
} else {
|
|
306
|
+
runOnUI(function () {
|
|
307
|
+
"worklet";
|
|
308
|
+
|
|
309
|
+
sharedValue.value = config.type === "spring" ? withSpring(next, config, cb) : withTiming(next, config, cb);
|
|
310
|
+
})();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
263
313
|
},
|
|
264
314
|
stop() {
|
|
265
|
-
"worklet";
|
|
266
|
-
|
|
267
315
|
cancelAnimation(sharedValue);
|
|
268
316
|
}
|
|
269
317
|
};
|
|
@@ -274,119 +322,179 @@ function createAnimations(animationsConfig) {
|
|
|
274
322
|
// =========================================================================
|
|
275
323
|
useAnimatedNumberReaction(param, onValue) {
|
|
276
324
|
var {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
325
|
+
value
|
|
326
|
+
} = param;
|
|
327
|
+
var instance = value.getInstance();
|
|
280
328
|
return useAnimatedReaction(function () {
|
|
281
329
|
return instance.value;
|
|
282
330
|
}, function (next, prev) {
|
|
283
|
-
prev !== next
|
|
331
|
+
if (prev !== next) {
|
|
332
|
+
runOnJS(onValue)(next);
|
|
333
|
+
}
|
|
284
334
|
}, [onValue, instance]);
|
|
285
335
|
},
|
|
286
336
|
// =========================================================================
|
|
287
337
|
// useAnimatedNumberStyle - Create animated styles from values
|
|
288
338
|
// =========================================================================
|
|
289
339
|
useAnimatedNumberStyle(val, getStyle) {
|
|
290
|
-
var instance = val.getInstance()
|
|
291
|
-
|
|
292
|
-
|
|
340
|
+
var instance = val.getInstance();
|
|
341
|
+
if (isWeb) {
|
|
342
|
+
return useAnimatedStyle(function () {
|
|
343
|
+
"worklet";
|
|
344
|
+
|
|
345
|
+
return getStyle(instance.value);
|
|
293
346
|
}, [instance, getStyle]);
|
|
347
|
+
}
|
|
348
|
+
var styleVal = useSharedValue(getStyle(instance.value));
|
|
349
|
+
useAnimatedReaction(function () {
|
|
350
|
+
"worklet";
|
|
351
|
+
|
|
352
|
+
return instance.value;
|
|
353
|
+
}, function (current, previous) {
|
|
354
|
+
"worklet";
|
|
355
|
+
|
|
356
|
+
if (current !== previous) {
|
|
357
|
+
styleVal.value = getStyle(current);
|
|
358
|
+
}
|
|
359
|
+
});
|
|
294
360
|
return useAnimatedStyle(function () {
|
|
295
|
-
|
|
296
|
-
|
|
361
|
+
"worklet";
|
|
362
|
+
|
|
363
|
+
return styleVal.value;
|
|
364
|
+
});
|
|
365
|
+
},
|
|
366
|
+
useAnimatedNumbersStyle(vals, getStyle) {
|
|
367
|
+
var instances = vals.map(function (v) {
|
|
368
|
+
return v.getInstance();
|
|
369
|
+
});
|
|
370
|
+
return useAnimatedStyle(function () {
|
|
371
|
+
"worklet";
|
|
372
|
+
|
|
373
|
+
var currentValues = instances.map(function (inst) {
|
|
374
|
+
return inst.value;
|
|
375
|
+
});
|
|
376
|
+
return getStyle(...currentValues);
|
|
377
|
+
}, isWeb ? [getStyle, ...instances] : void 0);
|
|
297
378
|
},
|
|
298
379
|
// =========================================================================
|
|
299
380
|
// useAnimations - Main animation hook for components
|
|
300
381
|
// =========================================================================
|
|
301
382
|
useAnimations(animationProps) {
|
|
302
383
|
var {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
384
|
+
props,
|
|
385
|
+
presence,
|
|
386
|
+
style,
|
|
387
|
+
componentState,
|
|
388
|
+
useStyleEmitter,
|
|
389
|
+
themeName,
|
|
390
|
+
stateRef,
|
|
391
|
+
styleState
|
|
392
|
+
} = animationProps;
|
|
393
|
+
var isHydrating = componentState.unmounted === true;
|
|
394
|
+
var isMounting = componentState.unmounted === "should-enter";
|
|
395
|
+
var isEntering = !!componentState.unmounted;
|
|
396
|
+
var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;
|
|
397
|
+
var wasEnteringRef = useRef(isEntering);
|
|
398
|
+
var justFinishedEntering = wasEnteringRef.current && !isEntering;
|
|
318
399
|
React.useEffect(function () {
|
|
319
400
|
wasEnteringRef.current = isEntering;
|
|
320
401
|
});
|
|
321
|
-
var _styleState_effectiveTransition
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
402
|
+
var _styleState_effectiveTransition;
|
|
403
|
+
var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;
|
|
404
|
+
var normalized = normalizeTransition(effectiveTransition);
|
|
405
|
+
var animationState = isExiting ? "exit" : isMounting || justFinishedEntering ? "enter" : "default";
|
|
406
|
+
var animationKey = getEffectiveAnimation(normalized, animationState);
|
|
407
|
+
var disableAnimation = isHydrating || !animationKey;
|
|
408
|
+
var isDark = (themeName === null || themeName === void 0 ? void 0 : themeName.startsWith("dark")) || false;
|
|
409
|
+
var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];
|
|
410
|
+
var exitCycleIdRef = useRef(0);
|
|
411
|
+
var pendingExitKeysRef = useRef(/* @__PURE__ */new Set());
|
|
412
|
+
var exitCompletedRef = useRef(false);
|
|
413
|
+
var wasExitingRef = useRef(false);
|
|
414
|
+
var justStartedExiting = isExiting && !wasExitingRef.current;
|
|
415
|
+
var justStoppedExiting = !isExiting && wasExitingRef.current;
|
|
416
|
+
var markExitKeyDone = useEvent(function (key3, cycleId, finished) {
|
|
417
|
+
if (cycleId !== exitCycleIdRef.current) return;
|
|
418
|
+
if (exitCompletedRef.current) return;
|
|
419
|
+
pendingExitKeysRef.current.delete(key3);
|
|
420
|
+
if (pendingExitKeysRef.current.size === 0) {
|
|
421
|
+
exitCompletedRef.current = true;
|
|
422
|
+
sendExitComplete === null || sendExitComplete === void 0 ? void 0 : sendExitComplete();
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
var isExitingRef = useSharedValue(isExiting);
|
|
426
|
+
var exitCycleIdShared = useSharedValue(exitCycleIdRef.current);
|
|
427
|
+
if (justStartedExiting) {
|
|
428
|
+
exitCycleIdRef.current++;
|
|
429
|
+
exitCompletedRef.current = false;
|
|
430
|
+
pendingExitKeysRef.current.clear();
|
|
431
|
+
}
|
|
432
|
+
if (justStoppedExiting) {
|
|
433
|
+
exitCycleIdRef.current++;
|
|
434
|
+
pendingExitKeysRef.current.clear();
|
|
435
|
+
}
|
|
436
|
+
useIsomorphicLayoutEffect(function () {
|
|
437
|
+
isExitingRef.value = isExiting;
|
|
438
|
+
exitCycleIdShared.value = exitCycleIdRef.current;
|
|
439
|
+
}, [isExiting, exitCycleIdRef.current]);
|
|
440
|
+
React.useEffect(function () {
|
|
343
441
|
wasExitingRef.current = isExiting;
|
|
344
442
|
});
|
|
345
|
-
var animatedTargetsRef = useSharedValue(null)
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
443
|
+
var animatedTargetsRef = useSharedValue(null);
|
|
444
|
+
var staticTargetsRef = useSharedValue(null);
|
|
445
|
+
var transformTargetsRef = useSharedValue(null);
|
|
446
|
+
var {
|
|
447
|
+
animatedStyles,
|
|
448
|
+
staticStyles
|
|
449
|
+
} = useMemo(function () {
|
|
450
|
+
var animated = {};
|
|
451
|
+
var staticStyles2 = {};
|
|
452
|
+
var animateOnly2 = props.animateOnly;
|
|
453
|
+
for (var key3 in style) {
|
|
454
|
+
var rawValue = style[key3];
|
|
455
|
+
var value = resolveDynamicValue(rawValue, isDark);
|
|
456
|
+
if (value === void 0) continue;
|
|
457
|
+
if (disableAnimation) {
|
|
458
|
+
staticStyles2[key3] = value;
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
if (canAnimateProperty(key3, value, animateOnly2)) {
|
|
462
|
+
animated[key3] = value;
|
|
463
|
+
} else {
|
|
464
|
+
staticStyles2[key3] = value;
|
|
365
465
|
}
|
|
366
|
-
|
|
466
|
+
}
|
|
467
|
+
if (isMounting) {
|
|
468
|
+
for (var key1 in animated) {
|
|
469
|
+
staticStyles2[key1] = animated[key1];
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return {
|
|
473
|
+
animatedStyles: animated,
|
|
474
|
+
staticStyles: staticStyles2
|
|
475
|
+
};
|
|
476
|
+
}, [disableAnimation, style, isDark, isMounting, props.animateOnly]);
|
|
477
|
+
var {
|
|
478
|
+
baseConfig,
|
|
479
|
+
propertyConfigs
|
|
480
|
+
} = useMemo(function () {
|
|
481
|
+
if (isHydrating) {
|
|
367
482
|
return {
|
|
368
|
-
animatedStyles: animated,
|
|
369
|
-
staticStyles: staticStyles2
|
|
370
|
-
};
|
|
371
|
-
}, [disableAnimation, style, isDark, isMounting, props.animateOnly]),
|
|
372
|
-
{
|
|
373
|
-
baseConfig,
|
|
374
|
-
propertyConfigs
|
|
375
|
-
} = useMemo(function () {
|
|
376
|
-
return isHydrating ? {
|
|
377
483
|
baseConfig: {
|
|
378
484
|
type: "timing",
|
|
379
485
|
duration: 0
|
|
380
486
|
},
|
|
381
487
|
propertyConfigs: {}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
return buildTransitionConfig(props.transition, animations, animationState, getStyleKeys(animatedStyles));
|
|
491
|
+
}, [isHydrating, props.transition, animatedStyles, animationState]);
|
|
492
|
+
var configRef = useSharedValue({
|
|
493
|
+
baseConfig,
|
|
494
|
+
propertyConfigs,
|
|
495
|
+
disableAnimation,
|
|
496
|
+
isHydrating
|
|
497
|
+
});
|
|
390
498
|
useIsomorphicLayoutEffect(function () {
|
|
391
499
|
configRef.set({
|
|
392
500
|
baseConfig,
|
|
@@ -394,16 +502,17 @@ function createAnimations(animationsConfig) {
|
|
|
394
502
|
disableAnimation,
|
|
395
503
|
isHydrating
|
|
396
504
|
});
|
|
397
|
-
}, [baseConfig, propertyConfigs, disableAnimation, isHydrating])
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
505
|
+
}, [baseConfig, propertyConfigs, disableAnimation, isHydrating]);
|
|
506
|
+
useStyleEmitter === null || useStyleEmitter === void 0 ? void 0 : useStyleEmitter(function (nextStyle, effectiveTransition2) {
|
|
507
|
+
var animateOnly2 = props.animateOnly;
|
|
508
|
+
var animated = {};
|
|
509
|
+
var statics = {};
|
|
510
|
+
var transforms2 = [];
|
|
511
|
+
var transitionToUse = effectiveTransition2 !== null && effectiveTransition2 !== void 0 ? effectiveTransition2 : props.transition;
|
|
512
|
+
var {
|
|
513
|
+
baseConfig: newBase,
|
|
514
|
+
propertyConfigs: newPropertyConfigs
|
|
515
|
+
} = buildTransitionConfig(transitionToUse, animations, animationState, getStyleKeys(nextStyle));
|
|
407
516
|
configRef.set({
|
|
408
517
|
baseConfig: newBase,
|
|
409
518
|
propertyConfigs: newPropertyConfigs,
|
|
@@ -411,172 +520,220 @@ function createAnimations(animationsConfig) {
|
|
|
411
520
|
isHydrating: configRef.get().isHydrating
|
|
412
521
|
});
|
|
413
522
|
for (var key3 in nextStyle) {
|
|
414
|
-
var rawValue = nextStyle[key3]
|
|
415
|
-
|
|
416
|
-
if (value
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
523
|
+
var rawValue = nextStyle[key3];
|
|
524
|
+
var value = resolveDynamicValue(rawValue, isDark);
|
|
525
|
+
if (value == void 0) continue;
|
|
526
|
+
if (configRef.get().disableAnimation) {
|
|
527
|
+
statics[key3] = value;
|
|
528
|
+
continue;
|
|
529
|
+
}
|
|
530
|
+
if (key3 === "transform" && Array.isArray(value)) {
|
|
531
|
+
var _iteratorNormalCompletion2 = true,
|
|
532
|
+
_didIteratorError2 = false,
|
|
533
|
+
_iteratorError2 = void 0;
|
|
534
|
+
try {
|
|
535
|
+
for (var _iterator2 = value[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
536
|
+
var t2 = _step2.value;
|
|
537
|
+
if (t2 && (typeof t2 === "undefined" ? "undefined" : _type_of(t2)) === "object") {
|
|
538
|
+
var tKey2 = Object.keys(t2)[0];
|
|
539
|
+
var tVal = t2[tKey2];
|
|
540
|
+
if (typeof tVal === "number" || typeof tVal === "string") {
|
|
541
|
+
transforms2.push(t2);
|
|
432
542
|
}
|
|
433
543
|
}
|
|
434
|
-
}
|
|
435
|
-
|
|
544
|
+
}
|
|
545
|
+
} catch (err) {
|
|
546
|
+
_didIteratorError2 = true;
|
|
547
|
+
_iteratorError2 = err;
|
|
548
|
+
} finally {
|
|
549
|
+
try {
|
|
550
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
551
|
+
_iterator2.return();
|
|
552
|
+
}
|
|
436
553
|
} finally {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
} finally {
|
|
440
|
-
if (_didIteratorError2) throw _iteratorError2;
|
|
554
|
+
if (_didIteratorError2) {
|
|
555
|
+
throw _iteratorError2;
|
|
441
556
|
}
|
|
442
557
|
}
|
|
443
|
-
continue;
|
|
444
558
|
}
|
|
445
|
-
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
if (canAnimateProperty(key3, value, animateOnly2)) {
|
|
562
|
+
animated[key3] = value;
|
|
563
|
+
} else {
|
|
564
|
+
statics[key3] = value;
|
|
446
565
|
}
|
|
447
566
|
}
|
|
448
|
-
animatedTargetsRef.set(animated)
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
567
|
+
animatedTargetsRef.set(animated);
|
|
568
|
+
staticTargetsRef.set(statics);
|
|
569
|
+
transformTargetsRef.set(transforms2);
|
|
570
|
+
if (process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile") {
|
|
571
|
+
console.info("[animations-reanimated] useStyleEmitter update", {
|
|
572
|
+
animated,
|
|
573
|
+
statics,
|
|
574
|
+
transforms: transforms2
|
|
575
|
+
});
|
|
576
|
+
}
|
|
453
577
|
});
|
|
454
|
-
var exitKeysRegistered = useRef(
|
|
578
|
+
var exitKeysRegistered = useRef(false);
|
|
455
579
|
if (justStartedExiting && sendExitComplete) {
|
|
456
|
-
var exitKeys = []
|
|
457
|
-
|
|
458
|
-
for (var key2 in animatedStyles)
|
|
580
|
+
var exitKeys = [];
|
|
581
|
+
var animateOnly = props.animateOnly;
|
|
582
|
+
for (var key2 in animatedStyles) {
|
|
583
|
+
if (key2 === "transform") continue;
|
|
584
|
+
if (canAnimateProperty(key2, animatedStyles[key2], animateOnly)) {
|
|
585
|
+
exitKeys.push(key2);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
459
588
|
var transforms = animatedStyles.transform;
|
|
460
589
|
if (transforms && Array.isArray(transforms)) {
|
|
461
|
-
var _iteratorNormalCompletion =
|
|
462
|
-
_didIteratorError =
|
|
590
|
+
var _iteratorNormalCompletion = true,
|
|
591
|
+
_didIteratorError = false,
|
|
463
592
|
_iteratorError = void 0;
|
|
464
593
|
try {
|
|
465
|
-
for (var _iterator = transforms[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion =
|
|
594
|
+
for (var _iterator = transforms[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
466
595
|
var t = _step.value;
|
|
467
|
-
if (t)
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
596
|
+
if (!t) continue;
|
|
597
|
+
var tKey = Object.keys(t)[0];
|
|
598
|
+
if (tKey) {
|
|
599
|
+
if (animateOnly && !animateOnly.includes(tKey)) {
|
|
600
|
+
continue;
|
|
472
601
|
}
|
|
602
|
+
exitKeys.push(`transform:${tKey}`);
|
|
473
603
|
}
|
|
474
604
|
}
|
|
475
605
|
} catch (err) {
|
|
476
|
-
_didIteratorError =
|
|
606
|
+
_didIteratorError = true;
|
|
607
|
+
_iteratorError = err;
|
|
477
608
|
} finally {
|
|
478
609
|
try {
|
|
479
|
-
!_iteratorNormalCompletion && _iterator.return != null
|
|
610
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
611
|
+
_iterator.return();
|
|
612
|
+
}
|
|
480
613
|
} finally {
|
|
481
|
-
if (_didIteratorError)
|
|
614
|
+
if (_didIteratorError) {
|
|
615
|
+
throw _iteratorError;
|
|
616
|
+
}
|
|
482
617
|
}
|
|
483
618
|
}
|
|
484
619
|
}
|
|
485
|
-
pendingExitKeysRef.current = new Set(exitKeys)
|
|
620
|
+
pendingExitKeysRef.current = new Set(exitKeys);
|
|
621
|
+
exitKeysRegistered.current = exitKeys.length > 0;
|
|
486
622
|
}
|
|
487
623
|
React.useEffect(function () {
|
|
488
|
-
!justStartedExiting || !sendExitComplete
|
|
624
|
+
if (!justStartedExiting || !sendExitComplete) return;
|
|
625
|
+
if (!exitKeysRegistered.current && pendingExitKeysRef.current.size === 0) {
|
|
626
|
+
if (!exitCompletedRef.current) {
|
|
627
|
+
exitCompletedRef.current = true;
|
|
628
|
+
sendExitComplete();
|
|
629
|
+
}
|
|
630
|
+
}
|
|
489
631
|
}, [justStartedExiting, sendExitComplete]);
|
|
490
632
|
var animatedStyle = useAnimatedStyle(function () {
|
|
491
633
|
"worklet";
|
|
492
634
|
|
|
493
635
|
var _loop = function (key12) {
|
|
494
636
|
if (key12 === "transform") return "continue";
|
|
495
|
-
var targetValue = animatedValues[key12]
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
637
|
+
var targetValue = animatedValues[key12];
|
|
638
|
+
var _config_propertyConfigs_key;
|
|
639
|
+
var propConfig = (_config_propertyConfigs_key = config.propertyConfigs[key12]) !== null && _config_propertyConfigs_key !== void 0 ? _config_propertyConfigs_key : config.baseConfig;
|
|
640
|
+
var callback = void 0;
|
|
499
641
|
if (currentlyExiting) {
|
|
500
|
-
var capturedKey = key12
|
|
501
|
-
|
|
642
|
+
var capturedKey = key12;
|
|
643
|
+
var capturedCycleId = currentCycleId;
|
|
502
644
|
callback = function (finished) {
|
|
503
645
|
"worklet";
|
|
504
646
|
|
|
505
|
-
runOnJS(markExitKeyDone)(capturedKey, capturedCycleId, finished
|
|
647
|
+
runOnJS(markExitKeyDone)(capturedKey, capturedCycleId, finished !== null && finished !== void 0 ? finished : false);
|
|
506
648
|
};
|
|
507
649
|
}
|
|
508
650
|
result[key12] = applyAnimation(targetValue, propConfig, callback);
|
|
509
651
|
};
|
|
510
|
-
if (disableAnimation || isHydrating)
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
652
|
+
if (disableAnimation || isHydrating) {
|
|
653
|
+
return {};
|
|
654
|
+
}
|
|
655
|
+
var result = {};
|
|
656
|
+
var config = configRef.get();
|
|
657
|
+
var emitterAnimated = animatedTargetsRef.value;
|
|
658
|
+
var emitterStatic = staticTargetsRef.value;
|
|
659
|
+
var emitterTransforms = transformTargetsRef.value;
|
|
660
|
+
var hasEmitterUpdates = emitterAnimated !== null;
|
|
661
|
+
var animatedValues = hasEmitterUpdates ? emitterAnimated : animatedStyles;
|
|
662
|
+
var staticValues = hasEmitterUpdates ? emitterStatic : {};
|
|
663
|
+
var currentlyExiting = isExitingRef.value;
|
|
664
|
+
var currentCycleId = exitCycleIdShared.value;
|
|
665
|
+
for (var key3 in staticValues) {
|
|
666
|
+
result[key3] = staticValues[key3];
|
|
667
|
+
}
|
|
522
668
|
for (var key1 in animatedValues) _loop(key1);
|
|
523
669
|
var transforms2 = hasEmitterUpdates ? emitterTransforms : animatedStyles.transform;
|
|
524
670
|
if (transforms2 && Array.isArray(transforms2)) {
|
|
525
|
-
var validTransforms = []
|
|
526
|
-
|
|
527
|
-
_didIteratorError2 =
|
|
671
|
+
var validTransforms = [];
|
|
672
|
+
var _iteratorNormalCompletion2 = true,
|
|
673
|
+
_didIteratorError2 = false,
|
|
528
674
|
_iteratorError2 = void 0;
|
|
529
675
|
try {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
676
|
+
var _loop1 = function () {
|
|
677
|
+
var t2 = _step2.value;
|
|
678
|
+
if (!t2) return "continue";
|
|
679
|
+
var keys = Object.keys(t2);
|
|
680
|
+
if (keys.length === 0) return "continue";
|
|
681
|
+
var value = t2[keys[0]];
|
|
682
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
683
|
+
var transformKey = Object.keys(t2)[0];
|
|
684
|
+
var targetValue = t2[transformKey];
|
|
685
|
+
var _config_propertyConfigs_transformKey;
|
|
686
|
+
var propConfig = (_config_propertyConfigs_transformKey = config.propertyConfigs[transformKey]) !== null && _config_propertyConfigs_transformKey !== void 0 ? _config_propertyConfigs_transformKey : config.baseConfig;
|
|
687
|
+
var callback = void 0;
|
|
688
|
+
if (currentlyExiting) {
|
|
689
|
+
var capturedKey = `transform:${transformKey}`;
|
|
690
|
+
var capturedCycleId = currentCycleId;
|
|
691
|
+
callback = function (finished) {
|
|
692
|
+
"worklet";
|
|
547
693
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
validTransforms.push({
|
|
552
|
-
[transformKey]: applyAnimation(targetValue, propConfig, callback)
|
|
553
|
-
});
|
|
694
|
+
runOnJS(markExitKeyDone)(capturedKey, capturedCycleId, finished !== null && finished !== void 0 ? finished : false);
|
|
695
|
+
};
|
|
554
696
|
}
|
|
555
|
-
|
|
697
|
+
validTransforms.push({
|
|
698
|
+
[transformKey]: applyAnimation(targetValue, propConfig, callback)
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
for (var _iterator2 = transforms2[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) _loop1();
|
|
556
703
|
} catch (err) {
|
|
557
|
-
_didIteratorError2 =
|
|
704
|
+
_didIteratorError2 = true;
|
|
705
|
+
_iteratorError2 = err;
|
|
558
706
|
} finally {
|
|
559
707
|
try {
|
|
560
|
-
!_iteratorNormalCompletion2 && _iterator2.return != null
|
|
708
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
|
|
709
|
+
_iterator2.return();
|
|
710
|
+
}
|
|
561
711
|
} finally {
|
|
562
|
-
if (_didIteratorError2)
|
|
712
|
+
if (_didIteratorError2) {
|
|
713
|
+
throw _iteratorError2;
|
|
714
|
+
}
|
|
563
715
|
}
|
|
564
716
|
}
|
|
565
|
-
validTransforms.length > 0
|
|
717
|
+
if (validTransforms.length > 0) {
|
|
718
|
+
result.transform = validTransforms;
|
|
719
|
+
}
|
|
566
720
|
}
|
|
567
721
|
return result;
|
|
568
|
-
}, [animatedStyles, baseConfig, propertyConfigs, disableAnimation, isHydrating,
|
|
569
|
-
//
|
|
570
|
-
animatedTargetsRef, staticTargetsRef, transformTargetsRef, isExitingRef, exitCycleIdShared, markExitKeyDone]);
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
722
|
+
}, isWeb ? [animatedStyles, baseConfig, propertyConfigs, disableAnimation, isHydrating,
|
|
723
|
+
// pass SharedValues so the mapper watches them on web (no babel plugin)
|
|
724
|
+
animatedTargetsRef, staticTargetsRef, transformTargetsRef, isExitingRef, exitCycleIdShared, markExitKeyDone] : void 0);
|
|
725
|
+
if (process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile") {
|
|
726
|
+
console.info("[animations-reanimated] useAnimations", {
|
|
727
|
+
animationKey,
|
|
728
|
+
componentState,
|
|
729
|
+
isExiting,
|
|
730
|
+
animatedStyles,
|
|
731
|
+
staticStyles,
|
|
732
|
+
baseConfig,
|
|
733
|
+
propertyConfigs
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
return {
|
|
580
737
|
style: [staticStyles, animatedStyle]
|
|
581
738
|
};
|
|
582
739
|
}
|