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