@hanzogui/animations-motion 8.3.0 → 8.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/createAnimations.js +804 -0
- package/dist/cjs/createAnimations.js.map +1 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/polyfill.js +6 -0
- package/dist/cjs/polyfill.js.map +1 -0
- package/dist/esm/createAnimations.js +799 -0
- package/dist/esm/createAnimations.js.map +1 -0
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/polyfill.js +6 -0
- package/dist/esm/polyfill.js.map +1 -0
- package/dist/native/createAnimations.js +799 -0
- package/dist/native/createAnimations.js.map +1 -0
- package/dist/native/index.js +20 -0
- package/dist/native/index.js.map +1 -0
- package/dist/native/polyfill.js +6 -0
- package/dist/native/polyfill.js.map +1 -0
- package/package.json +17 -17
- package/src/createAnimations.tsx +1 -1
- package/src/index.ts +2 -2
- package/types/createAnimations.d.ts +2 -3
- package/types/createAnimations.d.ts.map +1 -11
- package/types/index.d.ts +2 -3
- package/types/index.d.ts.map +1 -11
- package/types/index.native.d.ts +1 -2
- package/types/index.native.d.ts.map +1 -11
- package/types/polyfill.d.ts +0 -1
- package/types/polyfill.d.ts.map +1 -11
- package/dist/cjs/createAnimations.cjs +0 -720
- package/dist/cjs/createAnimations.native.js +0 -844
- package/dist/cjs/createAnimations.native.js.map +0 -1
- package/dist/cjs/index.cjs +0 -21
- package/dist/cjs/index.native.js +0 -45
- package/dist/cjs/index.native.js.map +0 -1
- package/dist/cjs/polyfill.cjs +0 -3
- package/dist/cjs/polyfill.native.js +0 -6
- package/dist/cjs/polyfill.native.js.map +0 -1
- package/dist/esm/createAnimations.mjs +0 -683
- package/dist/esm/createAnimations.mjs.map +0 -1
- package/dist/esm/createAnimations.native.js +0 -804
- package/dist/esm/createAnimations.native.js.map +0 -1
- package/dist/esm/index.mjs +0 -3
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js +0 -17
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/polyfill.mjs +0 -4
- package/dist/esm/polyfill.mjs.map +0 -1
- package/dist/esm/polyfill.native.js +0 -4
- package/dist/esm/polyfill.native.js.map +0 -1
|
@@ -1,804 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getEffectiveAnimation, normalizeTransition } from "@hanzogui/animation-helpers";
|
|
3
|
-
import { ResetPresence, usePresence } from "@hanzogui/use-presence";
|
|
4
|
-
import { fixStyles, getConfig, getSplitStyles, hooks, styleToCSS, Text, useComposedRefs, useIsomorphicLayoutEffect, useThemeWithState, View } from "@hanzogui/web";
|
|
5
|
-
import { useAnimate, useMotionValue, useMotionValueEvent } from "motion/react";
|
|
6
|
-
import React, { forwardRef, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
7
|
-
function _instanceof(left, right) {
|
|
8
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
9
|
-
return !!right[Symbol.hasInstance](left);
|
|
10
|
-
} else {
|
|
11
|
-
return left instanceof right;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function _type_of(obj) {
|
|
15
|
-
"@swc/helpers - typeof";
|
|
16
|
-
|
|
17
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
18
|
-
}
|
|
19
|
-
var isServer = typeof window === "undefined";
|
|
20
|
-
function useAnimateSSRSafe() {
|
|
21
|
-
if (isServer) {
|
|
22
|
-
return [useRef(null), function () {}];
|
|
23
|
-
}
|
|
24
|
-
return useAnimate();
|
|
25
|
-
}
|
|
26
|
-
var MotionValueStrategy = /* @__PURE__ */new WeakMap();
|
|
27
|
-
var PendingMotionOnFinish = /* @__PURE__ */new WeakMap();
|
|
28
|
-
function settlePendingMotionOnFinish(mv, controls) {
|
|
29
|
-
var onFinish = PendingMotionOnFinish.get(mv);
|
|
30
|
-
if (!onFinish) return;
|
|
31
|
-
PendingMotionOnFinish.delete(mv);
|
|
32
|
-
controls.then(function () {
|
|
33
|
-
return onFinish();
|
|
34
|
-
}).catch(function () {
|
|
35
|
-
return onFinish();
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
function createAnimations(animations) {
|
|
39
|
-
var isHydratingGlobal;
|
|
40
|
-
var hydratingComponents = /* @__PURE__ */new Set();
|
|
41
|
-
return {
|
|
42
|
-
View: MotionView,
|
|
43
|
-
Text: MotionText,
|
|
44
|
-
isReactNative: false,
|
|
45
|
-
inputStyle: "css",
|
|
46
|
-
outputStyle: "inline",
|
|
47
|
-
avoidReRenders: true,
|
|
48
|
-
animations,
|
|
49
|
-
usePresence,
|
|
50
|
-
ResetPresence,
|
|
51
|
-
onMount() {
|
|
52
|
-
isHydratingGlobal = false;
|
|
53
|
-
hydratingComponents.forEach(function (cb) {
|
|
54
|
-
return cb();
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
|
-
useAnimations: function (animationProps) {
|
|
58
|
-
if (isHydratingGlobal === void 0 && !getConfig().settings.disableSSR) {
|
|
59
|
-
isHydratingGlobal = true;
|
|
60
|
-
}
|
|
61
|
-
var {
|
|
62
|
-
props,
|
|
63
|
-
style,
|
|
64
|
-
componentState,
|
|
65
|
-
stateRef,
|
|
66
|
-
useStyleEmitter,
|
|
67
|
-
presence,
|
|
68
|
-
styleProps
|
|
69
|
-
} = animationProps;
|
|
70
|
-
var animationKey = Array.isArray(props.transition) ? props.transition[0] : props.transition;
|
|
71
|
-
var isComponentHydrating = componentState.unmounted === true;
|
|
72
|
-
var isMounting = componentState.unmounted === "should-enter";
|
|
73
|
-
var isEntering = !!componentState.unmounted;
|
|
74
|
-
var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;
|
|
75
|
-
var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];
|
|
76
|
-
var refs = useRef(null);
|
|
77
|
-
if (!refs.current) {
|
|
78
|
-
refs.current = {
|
|
79
|
-
isFirstRender: true,
|
|
80
|
-
lastDoAnimate: null,
|
|
81
|
-
lastDontAnimate: null,
|
|
82
|
-
controls: null,
|
|
83
|
-
lastAnimateAt: 0,
|
|
84
|
-
disposed: false,
|
|
85
|
-
wasExiting: false,
|
|
86
|
-
isExiting: false,
|
|
87
|
-
sendExitComplete: void 0,
|
|
88
|
-
animationState: "default",
|
|
89
|
-
frozenExitTarget: null,
|
|
90
|
-
exitCompleteScheduled: false,
|
|
91
|
-
wasEntering: false,
|
|
92
|
-
wasDisabled: false,
|
|
93
|
-
wasNoClass: !!styleProps.noClass
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
var justFinishedEntering = refs.current.wasEntering && !isEntering;
|
|
97
|
-
useEffect(function () {
|
|
98
|
-
refs.current.wasEntering = isEntering;
|
|
99
|
-
});
|
|
100
|
-
var animationState = isExiting ? "exit" : isMounting || justFinishedEntering ? "enter" : "default";
|
|
101
|
-
var disableAnimation = isComponentHydrating || isMounting || !animationKey;
|
|
102
|
-
var [scope, animate] = useAnimateSSRSafe();
|
|
103
|
-
refs.current.isExiting = isExiting;
|
|
104
|
-
refs.current.sendExitComplete = sendExitComplete;
|
|
105
|
-
refs.current.animationState = animationState;
|
|
106
|
-
var justStartedExiting = isExiting && !refs.current.wasExiting;
|
|
107
|
-
var justStoppedExiting = !isExiting && refs.current.wasExiting;
|
|
108
|
-
if (justStartedExiting || justStoppedExiting) {
|
|
109
|
-
refs.current.frozenExitTarget = null;
|
|
110
|
-
refs.current.exitCompleteScheduled = false;
|
|
111
|
-
}
|
|
112
|
-
useEffect(function () {
|
|
113
|
-
refs.current.wasExiting = isExiting;
|
|
114
|
-
});
|
|
115
|
-
var {
|
|
116
|
-
dontAnimate = {},
|
|
117
|
-
doAnimate,
|
|
118
|
-
animationOptions
|
|
119
|
-
} = getMotionAnimatedProps(props, style, disableAnimation, animationState);
|
|
120
|
-
var [firstRenderStyle] = useState(style);
|
|
121
|
-
if (refs.current.isFirstRender) {
|
|
122
|
-
refs.current.lastDontAnimate = firstRenderStyle;
|
|
123
|
-
}
|
|
124
|
-
var [isHydrating, setIsHydrating] = useState(isHydratingGlobal);
|
|
125
|
-
useLayoutEffect(function () {
|
|
126
|
-
if (isHydratingGlobal) {
|
|
127
|
-
hydratingComponents.add(function () {
|
|
128
|
-
setIsHydrating(false);
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
return function () {
|
|
132
|
-
refs.current.disposed = true;
|
|
133
|
-
};
|
|
134
|
-
}, []);
|
|
135
|
-
var flushAnimation = function (param) {
|
|
136
|
-
var {
|
|
137
|
-
doAnimate: doAnimateRaw = {},
|
|
138
|
-
animationOptions: passedOptions = {},
|
|
139
|
-
dontAnimate: dontAnimate2
|
|
140
|
-
} = param;
|
|
141
|
-
var startedControls = null;
|
|
142
|
-
var isCurrentlyExiting = refs.current.isExiting;
|
|
143
|
-
var currentSendExitComplete = refs.current.sendExitComplete;
|
|
144
|
-
var doAnimate2 = doAnimateRaw;
|
|
145
|
-
if (isCurrentlyExiting && refs.current.frozenExitTarget) {
|
|
146
|
-
doAnimate2 = refs.current.frozenExitTarget;
|
|
147
|
-
}
|
|
148
|
-
var _props_transition;
|
|
149
|
-
var animationOptions2 = isCurrentlyExiting && currentSendExitComplete ? getAnimationOptions((_props_transition = props.transition) !== null && _props_transition !== void 0 ? _props_transition : null, "exit") : passedOptions;
|
|
150
|
-
try {
|
|
151
|
-
var node = stateRef.current.host;
|
|
152
|
-
if (refs.current.isFirstRender) {
|
|
153
|
-
refs.current.lastDontAnimate = null;
|
|
154
|
-
refs.current.lastDoAnimate = null;
|
|
155
|
-
}
|
|
156
|
-
if (process.env.NODE_ENV === "development") {
|
|
157
|
-
if (props["debug"] && props["debug"] !== "profile") {
|
|
158
|
-
console.groupCollapsed(`[motion] animate (${JSON.stringify(getDiff(refs.current.lastDoAnimate, doAnimate2), null, 2)})`);
|
|
159
|
-
console.info({
|
|
160
|
-
props,
|
|
161
|
-
componentState,
|
|
162
|
-
doAnimate: doAnimate2,
|
|
163
|
-
dontAnimate: dontAnimate2,
|
|
164
|
-
animationOptions: animationOptions2,
|
|
165
|
-
animationProps,
|
|
166
|
-
lastDoAnimate: {
|
|
167
|
-
...refs.current.lastDoAnimate
|
|
168
|
-
},
|
|
169
|
-
lastDontAnimate: {
|
|
170
|
-
...refs.current.lastDontAnimate
|
|
171
|
-
},
|
|
172
|
-
isExiting,
|
|
173
|
-
style,
|
|
174
|
-
node
|
|
175
|
-
});
|
|
176
|
-
console.groupCollapsed(`trace >`);
|
|
177
|
-
console.trace();
|
|
178
|
-
console.groupEnd();
|
|
179
|
-
console.groupEnd();
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (!_instanceof(node, HTMLElement)) {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
var prevDont = refs.current.lastDontAnimate;
|
|
186
|
-
if (dontAnimate2) {
|
|
187
|
-
if (prevDont) {
|
|
188
|
-
removeRemovedStyles(prevDont, dontAnimate2, node, doAnimate2);
|
|
189
|
-
var changed = getDiff(prevDont, dontAnimate2);
|
|
190
|
-
if (changed) {
|
|
191
|
-
Object.assign(node.style, changed);
|
|
192
|
-
}
|
|
193
|
-
} else {
|
|
194
|
-
Object.assign(node.style, dontAnimate2);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
if (doAnimate2) {
|
|
198
|
-
if (prevDont) {
|
|
199
|
-
for (var key in prevDont) {
|
|
200
|
-
if (key in doAnimate2) {
|
|
201
|
-
node.style[key] = prevDont[key];
|
|
202
|
-
if (refs.current.lastDoAnimate) {
|
|
203
|
-
refs.current.lastDoAnimate[key] = prevDont[key];
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
var lastAnimated = refs.current.lastDoAnimate;
|
|
209
|
-
if (lastAnimated) {
|
|
210
|
-
removeRemovedStyles(lastAnimated, doAnimate2, node, dontAnimate2);
|
|
211
|
-
}
|
|
212
|
-
var diff = getDiff(refs.current.lastDoAnimate, doAnimate2);
|
|
213
|
-
if (diff) {
|
|
214
|
-
if (isCurrentlyExiting && !refs.current.frozenExitTarget) {
|
|
215
|
-
refs.current.frozenExitTarget = {
|
|
216
|
-
...doAnimate2
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
var isPopperPosition = node.hasAttribute("data-popper-animate-position");
|
|
220
|
-
var midFlightValues = null;
|
|
221
|
-
if (refs.current.controls) {
|
|
222
|
-
try {
|
|
223
|
-
var computed = getComputedStyle(node);
|
|
224
|
-
midFlightValues = {};
|
|
225
|
-
for (var key1 in diff) {
|
|
226
|
-
var val = computed[key1];
|
|
227
|
-
if (val !== void 0 && val !== "") {
|
|
228
|
-
midFlightValues[key1] = val;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
} catch (e) {}
|
|
232
|
-
if (isCurrentlyExiting) {
|
|
233
|
-
refs.current.controls.stop();
|
|
234
|
-
}
|
|
235
|
-
if (midFlightValues) {
|
|
236
|
-
for (var key2 in midFlightValues) {
|
|
237
|
-
;
|
|
238
|
-
node.style[key2] = midFlightValues[key2];
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if (isPopperPosition) {
|
|
242
|
-
var anims = node.getAnimations();
|
|
243
|
-
var _iteratorNormalCompletion = true,
|
|
244
|
-
_didIteratorError = false,
|
|
245
|
-
_iteratorError = void 0;
|
|
246
|
-
try {
|
|
247
|
-
for (var _iterator = anims[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
248
|
-
var anim = _step.value;
|
|
249
|
-
anim.cancel();
|
|
250
|
-
}
|
|
251
|
-
} catch (err) {
|
|
252
|
-
_didIteratorError = true;
|
|
253
|
-
_iteratorError = err;
|
|
254
|
-
} finally {
|
|
255
|
-
try {
|
|
256
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
257
|
-
_iterator.return();
|
|
258
|
-
}
|
|
259
|
-
} finally {
|
|
260
|
-
if (_didIteratorError) {
|
|
261
|
-
throw _iteratorError;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
var fixedDiff = fixTransparentColors(diff, refs.current.lastDoAnimate, doAnimate2);
|
|
268
|
-
if ((isPopperPosition || isCurrentlyExiting) && (midFlightValues === null || midFlightValues === void 0 ? void 0 : midFlightValues.transform) && fixedDiff.transform) {
|
|
269
|
-
fixedDiff.transform = [midFlightValues.transform, fixedDiff.transform];
|
|
270
|
-
}
|
|
271
|
-
startedControls = animate(scope.current, fixedDiff, animationOptions2);
|
|
272
|
-
refs.current.controls = startedControls;
|
|
273
|
-
refs.current.lastAnimateAt = Date.now();
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
refs.current.lastDontAnimate = dontAnimate2 ? {
|
|
277
|
-
...dontAnimate2
|
|
278
|
-
} : {};
|
|
279
|
-
refs.current.lastDoAnimate = doAnimate2 ? {
|
|
280
|
-
...doAnimate2
|
|
281
|
-
} : {};
|
|
282
|
-
} finally {
|
|
283
|
-
if (isCurrentlyExiting && currentSendExitComplete) {
|
|
284
|
-
if (startedControls) {
|
|
285
|
-
refs.current.exitCompleteScheduled = true;
|
|
286
|
-
startedControls.finished.then(function () {
|
|
287
|
-
if (refs.current.isExiting) {
|
|
288
|
-
currentSendExitComplete();
|
|
289
|
-
}
|
|
290
|
-
}).catch(function () {
|
|
291
|
-
if (refs.current.isExiting) {
|
|
292
|
-
currentSendExitComplete();
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
} else if (!refs.current.exitCompleteScheduled) {
|
|
296
|
-
currentSendExitComplete();
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
useStyleEmitter === null || useStyleEmitter === void 0 ? void 0 : useStyleEmitter(function (nextStyle, effectiveTransition) {
|
|
302
|
-
var _$animationProps = getMotionAnimatedProps(props, nextStyle, disableAnimation, refs.current.animationState, effectiveTransition);
|
|
303
|
-
flushAnimation(_$animationProps);
|
|
304
|
-
});
|
|
305
|
-
useIsomorphicLayoutEffect(function () {
|
|
306
|
-
if (refs.current.isFirstRender) {
|
|
307
|
-
refs.current.isFirstRender = false;
|
|
308
|
-
refs.current.wasDisabled = disableAnimation;
|
|
309
|
-
if (isHydrating) {
|
|
310
|
-
if (doAnimate && Object.keys(doAnimate).length > 0) {
|
|
311
|
-
refs.current.lastDoAnimate = {
|
|
312
|
-
...doAnimate
|
|
313
|
-
};
|
|
314
|
-
} else {
|
|
315
|
-
refs.current.lastDoAnimate = dontAnimate ? {
|
|
316
|
-
...dontAnimate
|
|
317
|
-
} : {};
|
|
318
|
-
}
|
|
319
|
-
refs.current.lastDontAnimate = dontAnimate ? {
|
|
320
|
-
...dontAnimate
|
|
321
|
-
} : {};
|
|
322
|
-
refs.current.lastAnimateAt = Date.now();
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
refs.current.lastDontAnimate = dontAnimate ? {
|
|
326
|
-
...dontAnimate
|
|
327
|
-
} : {};
|
|
328
|
-
refs.current.lastDoAnimate = doAnimate ? {
|
|
329
|
-
...doAnimate
|
|
330
|
-
} : {};
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
var justEnabled = refs.current.wasDisabled && !disableAnimation;
|
|
334
|
-
refs.current.wasDisabled = disableAnimation;
|
|
335
|
-
var justStrippedClasses = !refs.current.wasNoClass && !!styleProps.noClass;
|
|
336
|
-
refs.current.wasNoClass = !!styleProps.noClass;
|
|
337
|
-
if ((justEnabled || justStrippedClasses) && animationState !== "enter") {
|
|
338
|
-
var node = stateRef.current.host;
|
|
339
|
-
if (_instanceof(node, HTMLElement)) {
|
|
340
|
-
if (dontAnimate) Object.assign(node.style, dontAnimate);
|
|
341
|
-
if (doAnimate) Object.assign(node.style, doAnimate);
|
|
342
|
-
}
|
|
343
|
-
refs.current.lastDontAnimate = dontAnimate ? {
|
|
344
|
-
...dontAnimate
|
|
345
|
-
} : {};
|
|
346
|
-
refs.current.lastDoAnimate = doAnimate ? {
|
|
347
|
-
...doAnimate
|
|
348
|
-
} : {};
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
flushAnimation({
|
|
352
|
-
doAnimate,
|
|
353
|
-
dontAnimate,
|
|
354
|
-
animationOptions
|
|
355
|
-
});
|
|
356
|
-
}, [style, isExiting, disableAnimation, styleProps.noClass]);
|
|
357
|
-
if (process.env.NODE_ENV === "development") {
|
|
358
|
-
if (props["debug"] && props["debug"] !== "profile") {
|
|
359
|
-
console.groupCollapsed(`[motion] render`);
|
|
360
|
-
console.info({
|
|
361
|
-
style,
|
|
362
|
-
doAnimate,
|
|
363
|
-
dontAnimate,
|
|
364
|
-
scope,
|
|
365
|
-
animationOptions,
|
|
366
|
-
isExiting,
|
|
367
|
-
isFirstRender: refs.current.isFirstRender,
|
|
368
|
-
animationProps
|
|
369
|
-
});
|
|
370
|
-
console.groupEnd();
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
return {
|
|
374
|
-
style: firstRenderStyle,
|
|
375
|
-
ref: scope,
|
|
376
|
-
render: "div"
|
|
377
|
-
};
|
|
378
|
-
},
|
|
379
|
-
useAnimatedNumber(initial) {
|
|
380
|
-
var motionValue = useMotionValue(initial);
|
|
381
|
-
return React.useMemo(function () {
|
|
382
|
-
return {
|
|
383
|
-
getInstance() {
|
|
384
|
-
return motionValue;
|
|
385
|
-
},
|
|
386
|
-
getValue() {
|
|
387
|
-
return motionValue.get();
|
|
388
|
-
},
|
|
389
|
-
setValue(next) {
|
|
390
|
-
var config = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
|
|
391
|
-
type: "spring"
|
|
392
|
-
},
|
|
393
|
-
onFinish = arguments.length > 2 ? arguments[2] : void 0;
|
|
394
|
-
if (config.type === "direct") {
|
|
395
|
-
MotionValueStrategy.set(motionValue, {
|
|
396
|
-
type: "direct"
|
|
397
|
-
});
|
|
398
|
-
motionValue.set(next);
|
|
399
|
-
onFinish === null || onFinish === void 0 ? void 0 : onFinish();
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
MotionValueStrategy.set(motionValue, config);
|
|
403
|
-
if (onFinish) {
|
|
404
|
-
var prior = PendingMotionOnFinish.get(motionValue);
|
|
405
|
-
if (prior) {
|
|
406
|
-
PendingMotionOnFinish.delete(motionValue);
|
|
407
|
-
prior();
|
|
408
|
-
}
|
|
409
|
-
PendingMotionOnFinish.set(motionValue, onFinish);
|
|
410
|
-
}
|
|
411
|
-
motionValue.set(next);
|
|
412
|
-
},
|
|
413
|
-
stop() {
|
|
414
|
-
motionValue.stop();
|
|
415
|
-
}
|
|
416
|
-
};
|
|
417
|
-
}, [motionValue]);
|
|
418
|
-
},
|
|
419
|
-
useAnimatedNumberReaction(param, onValue) {
|
|
420
|
-
var {
|
|
421
|
-
value
|
|
422
|
-
} = param;
|
|
423
|
-
var instance = value.getInstance();
|
|
424
|
-
useMotionValueEvent(instance, "change", onValue);
|
|
425
|
-
},
|
|
426
|
-
useAnimatedNumberStyle(val, getStyleProp) {
|
|
427
|
-
var motionValue = val.getInstance();
|
|
428
|
-
var getStyleRef = useRef(getStyleProp);
|
|
429
|
-
getStyleRef.current = getStyleProp;
|
|
430
|
-
return useMemo(function () {
|
|
431
|
-
return {
|
|
432
|
-
getStyle: function (cur) {
|
|
433
|
-
return getStyleRef.current(cur);
|
|
434
|
-
},
|
|
435
|
-
motionValue
|
|
436
|
-
};
|
|
437
|
-
}, []);
|
|
438
|
-
},
|
|
439
|
-
useAnimatedNumbersStyle(vals, getStyleProp) {
|
|
440
|
-
var motionValues = vals.map(function (v) {
|
|
441
|
-
return v.getInstance();
|
|
442
|
-
});
|
|
443
|
-
var getStyleRef = useRef(getStyleProp);
|
|
444
|
-
getStyleRef.current = getStyleProp;
|
|
445
|
-
return useMemo(function () {
|
|
446
|
-
return {
|
|
447
|
-
getStyle: function () {
|
|
448
|
-
for (var _len = arguments.length, currentValues = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
449
|
-
currentValues[_key] = arguments[_key];
|
|
450
|
-
}
|
|
451
|
-
return getStyleRef.current(...currentValues);
|
|
452
|
-
},
|
|
453
|
-
motionValues
|
|
454
|
-
};
|
|
455
|
-
}, []);
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
function getMotionAnimatedProps(props, style, disable) {
|
|
459
|
-
var animationState = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "default",
|
|
460
|
-
transitionOverride = arguments.length > 4 ? arguments[4] : void 0;
|
|
461
|
-
if (disable) {
|
|
462
|
-
return {
|
|
463
|
-
dontAnimate: style
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
var _ref;
|
|
467
|
-
var animationOptions = getAnimationOptions((_ref = transitionOverride !== null && transitionOverride !== void 0 ? transitionOverride : props.transition) !== null && _ref !== void 0 ? _ref : null, animationState);
|
|
468
|
-
var dontAnimate;
|
|
469
|
-
var doAnimate;
|
|
470
|
-
var animateOnly = props.animateOnly;
|
|
471
|
-
for (var key in style) {
|
|
472
|
-
var value = style[key];
|
|
473
|
-
if (disableAnimationProps.has(key) || animateOnly && !animateOnly.includes(key)) {
|
|
474
|
-
dontAnimate || (dontAnimate = {});
|
|
475
|
-
dontAnimate[key] = value;
|
|
476
|
-
} else {
|
|
477
|
-
doAnimate || (doAnimate = {});
|
|
478
|
-
doAnimate[key] = value;
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
return {
|
|
482
|
-
dontAnimate,
|
|
483
|
-
doAnimate,
|
|
484
|
-
animationOptions
|
|
485
|
-
};
|
|
486
|
-
}
|
|
487
|
-
function getAnimationOptions(transitionProp) {
|
|
488
|
-
var animationState = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "default";
|
|
489
|
-
var normalized = normalizeTransition(transitionProp);
|
|
490
|
-
var effectiveKey = getEffectiveAnimation(normalized, animationState);
|
|
491
|
-
if (!effectiveKey && animationState === "default") {
|
|
492
|
-
effectiveKey = normalized.enter || normalized.exit || null;
|
|
493
|
-
}
|
|
494
|
-
var globalConfigOverride = normalized.config ? {
|
|
495
|
-
...normalized.config
|
|
496
|
-
} : void 0;
|
|
497
|
-
if (!effectiveKey && Object.keys(normalized.properties).length === 0 && !globalConfigOverride) {
|
|
498
|
-
return {};
|
|
499
|
-
}
|
|
500
|
-
var defaultConfig = effectiveKey ? withInferredType(animations[effectiveKey]) : null;
|
|
501
|
-
var delay = normalized.delay;
|
|
502
|
-
var result = {};
|
|
503
|
-
if (defaultConfig) {
|
|
504
|
-
Object.assign(result, defaultConfig);
|
|
505
|
-
}
|
|
506
|
-
if (globalConfigOverride) {
|
|
507
|
-
Object.assign(result, globalConfigOverride);
|
|
508
|
-
if (result.type === void 0 && result.duration !== void 0 && result.damping === void 0 && result.stiffness === void 0 && result.mass === void 0) {
|
|
509
|
-
result.type = "tween";
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
if (delay) {
|
|
513
|
-
result.delay = delay;
|
|
514
|
-
}
|
|
515
|
-
if (defaultConfig || globalConfigOverride || delay) {
|
|
516
|
-
result.default = {
|
|
517
|
-
...defaultConfig,
|
|
518
|
-
...globalConfigOverride,
|
|
519
|
-
...(delay ? {
|
|
520
|
-
delay
|
|
521
|
-
} : null)
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
var _iteratorNormalCompletion = true,
|
|
525
|
-
_didIteratorError = false,
|
|
526
|
-
_iteratorError = void 0;
|
|
527
|
-
try {
|
|
528
|
-
for (var _iterator = Object.entries(normalized.properties)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
529
|
-
var [propName, animationNameOrConfig] = _step.value;
|
|
530
|
-
if (typeof animationNameOrConfig === "string") {
|
|
531
|
-
result[propName] = withInferredType(animations[animationNameOrConfig]);
|
|
532
|
-
} else if (animationNameOrConfig && (typeof animationNameOrConfig === "undefined" ? "undefined" : _type_of(animationNameOrConfig)) === "object") {
|
|
533
|
-
var baseConfig = animationNameOrConfig.type ? withInferredType(animations[animationNameOrConfig.type]) : defaultConfig;
|
|
534
|
-
result[propName] = {
|
|
535
|
-
...baseConfig,
|
|
536
|
-
...animationNameOrConfig
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
} catch (err) {
|
|
541
|
-
_didIteratorError = true;
|
|
542
|
-
_iteratorError = err;
|
|
543
|
-
} finally {
|
|
544
|
-
try {
|
|
545
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
546
|
-
_iterator.return();
|
|
547
|
-
}
|
|
548
|
-
} finally {
|
|
549
|
-
if (_didIteratorError) {
|
|
550
|
-
throw _iteratorError;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
convertMsToS(result);
|
|
555
|
-
convertMsToS(result.default);
|
|
556
|
-
for (var key in result) {
|
|
557
|
-
if (key !== "default" && _type_of(result[key]) === "object") {
|
|
558
|
-
convertMsToS(result[key]);
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
return result;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
function withInferredType(config) {
|
|
565
|
-
if (!config) {
|
|
566
|
-
return {
|
|
567
|
-
type: "spring"
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
var isTimingBased = config.duration !== void 0 && config.damping === void 0 && config.stiffness === void 0 && config.mass === void 0;
|
|
571
|
-
return {
|
|
572
|
-
type: isTimingBased ? "tween" : "spring",
|
|
573
|
-
...config
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
|
-
function convertMsToS(config) {
|
|
577
|
-
if (!config) return;
|
|
578
|
-
if (typeof config.delay === "number") config.delay = config.delay / 1e3;
|
|
579
|
-
if (typeof config.duration === "number") {
|
|
580
|
-
var isTimingBased = config.type === "tween" || config.type === void 0 && config.damping === void 0 && config.stiffness === void 0 && config.mass === void 0;
|
|
581
|
-
if (isTimingBased) {
|
|
582
|
-
config.duration = config.duration / 1e3;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
function removeRemovedStyles(prev, next, node, dontClearIfIn) {
|
|
587
|
-
for (var key in prev) {
|
|
588
|
-
if (!(key in next)) {
|
|
589
|
-
if (dontClearIfIn && key in dontClearIfIn) {
|
|
590
|
-
continue;
|
|
591
|
-
}
|
|
592
|
-
node.style[key] = "";
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
var disableAnimationProps = /* @__PURE__ */new Set(["alignContent", "alignItems", "boxSizing", "contain", "containerType", "display", "flexBasis", "flexDirection", "fontFamily", "justifyContent", "overflow", "overflowX", "overflowY", "pointerEvents", "position", "textWrap", "userSelect"]);
|
|
597
|
-
var MotionView = createMotionView("div");
|
|
598
|
-
var MotionText = createMotionView("span");
|
|
599
|
-
function createMotionView(defaultTag) {
|
|
600
|
-
var isText = defaultTag === "span";
|
|
601
|
-
var Component = /* @__PURE__ */forwardRef(function (propsIn, ref) {
|
|
602
|
-
var _hooks_usePropsTransform;
|
|
603
|
-
var {
|
|
604
|
-
forwardedRef,
|
|
605
|
-
animation,
|
|
606
|
-
render = defaultTag,
|
|
607
|
-
style,
|
|
608
|
-
...propsRest
|
|
609
|
-
} = propsIn;
|
|
610
|
-
var [scope, animate] = useAnimateSSRSafe();
|
|
611
|
-
var hostRef = useRef(null);
|
|
612
|
-
var composedRefs = useComposedRefs(forwardedRef, ref, hostRef, scope);
|
|
613
|
-
var stateRef = useRef(null);
|
|
614
|
-
if (!stateRef.current) {
|
|
615
|
-
stateRef.current = {
|
|
616
|
-
get host() {
|
|
617
|
-
return hostRef.current;
|
|
618
|
-
}
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
var [_, state] = useThemeWithState({});
|
|
622
|
-
var styles = Array.isArray(style) ? style : [style];
|
|
623
|
-
var [animatedStyle, nonAnimatedStyles] = function () {
|
|
624
|
-
var animatedStyle2;
|
|
625
|
-
var nonAnimatedStyles2 = [];
|
|
626
|
-
var _iteratorNormalCompletion = true,
|
|
627
|
-
_didIteratorError = false,
|
|
628
|
-
_iteratorError = void 0;
|
|
629
|
-
try {
|
|
630
|
-
for (var _iterator = styles[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
631
|
-
var style2 = _step.value;
|
|
632
|
-
if (style2.getStyle) {
|
|
633
|
-
animatedStyle2 = style2;
|
|
634
|
-
} else {
|
|
635
|
-
nonAnimatedStyles2.push(style2);
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
} catch (err) {
|
|
639
|
-
_didIteratorError = true;
|
|
640
|
-
_iteratorError = err;
|
|
641
|
-
} finally {
|
|
642
|
-
try {
|
|
643
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
644
|
-
_iterator.return();
|
|
645
|
-
}
|
|
646
|
-
} finally {
|
|
647
|
-
if (_didIteratorError) {
|
|
648
|
-
throw _iteratorError;
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
return [animatedStyle2, nonAnimatedStyles2];
|
|
653
|
-
}();
|
|
654
|
-
function getProps(props2) {
|
|
655
|
-
var out = getSplitStyles(props2, isText ? Text.staticConfig : View.staticConfig, state === null || state === void 0 ? void 0 : state.theme, state === null || state === void 0 ? void 0 : state.name, {
|
|
656
|
-
unmounted: false
|
|
657
|
-
}, {
|
|
658
|
-
isAnimated: false,
|
|
659
|
-
noClass: true,
|
|
660
|
-
resolveValues: "auto"
|
|
661
|
-
});
|
|
662
|
-
if (!out) {
|
|
663
|
-
return {};
|
|
664
|
-
}
|
|
665
|
-
if (out.viewProps.style) {
|
|
666
|
-
fixStyles(out.viewProps.style);
|
|
667
|
-
styleToCSS(out.viewProps.style);
|
|
668
|
-
}
|
|
669
|
-
return out.viewProps;
|
|
670
|
-
}
|
|
671
|
-
var props = getProps({
|
|
672
|
-
...propsRest,
|
|
673
|
-
style: nonAnimatedStyles
|
|
674
|
-
});
|
|
675
|
-
var Element = render || "div";
|
|
676
|
-
var transformedProps = (_hooks_usePropsTransform = hooks.usePropsTransform) === null || _hooks_usePropsTransform === void 0 ? void 0 : _hooks_usePropsTransform.call(hooks, render, props, stateRef, false);
|
|
677
|
-
useEffect(function () {
|
|
678
|
-
if (!animatedStyle) return;
|
|
679
|
-
if (animatedStyle.motionValues) {
|
|
680
|
-
var mvs = animatedStyle.motionValues;
|
|
681
|
-
var unsubs = mvs.map(function (mv) {
|
|
682
|
-
return mv.on("change", function () {
|
|
683
|
-
var currentValues = mvs.map(function (v) {
|
|
684
|
-
return v.get();
|
|
685
|
-
});
|
|
686
|
-
var nextStyle = animatedStyle.getStyle(...currentValues);
|
|
687
|
-
var animationConfig = MotionValueStrategy.get(mv);
|
|
688
|
-
var node = hostRef.current;
|
|
689
|
-
var webStyle = getProps({
|
|
690
|
-
style: nextStyle
|
|
691
|
-
}).style;
|
|
692
|
-
if (webStyle && _instanceof(node, HTMLElement)) {
|
|
693
|
-
var motionAnimationConfig = (animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.type) === "timing" ? {
|
|
694
|
-
type: "tween",
|
|
695
|
-
duration: ((animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.duration) || 0) / 1e3
|
|
696
|
-
} : (animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.type) === "direct" ? {
|
|
697
|
-
type: "tween",
|
|
698
|
-
duration: 0
|
|
699
|
-
} : {
|
|
700
|
-
type: "spring",
|
|
701
|
-
...animationConfig
|
|
702
|
-
};
|
|
703
|
-
var controls = animate(node, webStyle, motionAnimationConfig);
|
|
704
|
-
settlePendingMotionOnFinish(mv, controls);
|
|
705
|
-
}
|
|
706
|
-
});
|
|
707
|
-
});
|
|
708
|
-
return function () {
|
|
709
|
-
return unsubs.forEach(function (fn) {
|
|
710
|
-
return fn();
|
|
711
|
-
});
|
|
712
|
-
};
|
|
713
|
-
}
|
|
714
|
-
if (!animatedStyle.motionValue) return;
|
|
715
|
-
return animatedStyle.motionValue.on("change", function (value) {
|
|
716
|
-
var nextStyle = animatedStyle.getStyle(value);
|
|
717
|
-
var animationConfig = MotionValueStrategy.get(animatedStyle.motionValue);
|
|
718
|
-
var node = hostRef.current;
|
|
719
|
-
var webStyle = getProps({
|
|
720
|
-
style: nextStyle
|
|
721
|
-
}).style;
|
|
722
|
-
if (webStyle && _instanceof(node, HTMLElement)) {
|
|
723
|
-
var motionAnimationConfig = (animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.type) === "timing" ? {
|
|
724
|
-
type: "tween",
|
|
725
|
-
duration: ((animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.duration) || 0) / 1e3
|
|
726
|
-
} : (animationConfig === null || animationConfig === void 0 ? void 0 : animationConfig.type) === "direct" ? {
|
|
727
|
-
type: "tween",
|
|
728
|
-
duration: 0
|
|
729
|
-
} : {
|
|
730
|
-
type: "spring",
|
|
731
|
-
...animationConfig
|
|
732
|
-
};
|
|
733
|
-
var controls = animate(node, webStyle, motionAnimationConfig);
|
|
734
|
-
settlePendingMotionOnFinish(animatedStyle.motionValue, controls);
|
|
735
|
-
}
|
|
736
|
-
});
|
|
737
|
-
}, [animatedStyle]);
|
|
738
|
-
return /* @__PURE__ */_jsx(Element, {
|
|
739
|
-
...transformedProps,
|
|
740
|
-
ref: composedRefs
|
|
741
|
-
});
|
|
742
|
-
});
|
|
743
|
-
Component["acceptRenderProp"] = true;
|
|
744
|
-
return Component;
|
|
745
|
-
}
|
|
746
|
-
function getDiff(previous, next) {
|
|
747
|
-
if (!previous) {
|
|
748
|
-
return next;
|
|
749
|
-
}
|
|
750
|
-
var diff = null;
|
|
751
|
-
for (var key in next) {
|
|
752
|
-
if (next[key] !== previous[key]) {
|
|
753
|
-
diff || (diff = {});
|
|
754
|
-
diff[key] = next[key];
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
return diff;
|
|
758
|
-
}
|
|
759
|
-
function fixTransparentColors(diff, previous, next) {
|
|
760
|
-
var result = diff;
|
|
761
|
-
for (var key in diff) {
|
|
762
|
-
if (diff[key] === "transparent") {
|
|
763
|
-
var fixed = "rgba(0, 0, 0, 0)";
|
|
764
|
-
var candidates = [previous === null || previous === void 0 ? void 0 : previous[key], next === null || next === void 0 ? void 0 : next[key]];
|
|
765
|
-
var _iteratorNormalCompletion = true,
|
|
766
|
-
_didIteratorError = false,
|
|
767
|
-
_iteratorError = void 0;
|
|
768
|
-
try {
|
|
769
|
-
for (var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
770
|
-
var candidate = _step.value;
|
|
771
|
-
if (typeof candidate === "string" && candidate !== "transparent") {
|
|
772
|
-
var rgbaMatch = candidate.match(/^rgba?\(([^,]+),\s*([^,]+),\s*([^,)]+)/);
|
|
773
|
-
if (rgbaMatch) {
|
|
774
|
-
fixed = `rgba(${rgbaMatch[1]}, ${rgbaMatch[2]}, ${rgbaMatch[3]}, 0)`;
|
|
775
|
-
break;
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
} catch (err) {
|
|
780
|
-
_didIteratorError = true;
|
|
781
|
-
_iteratorError = err;
|
|
782
|
-
} finally {
|
|
783
|
-
try {
|
|
784
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
785
|
-
_iterator.return();
|
|
786
|
-
}
|
|
787
|
-
} finally {
|
|
788
|
-
if (_didIteratorError) {
|
|
789
|
-
throw _iteratorError;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
if (result === diff) {
|
|
794
|
-
result = {
|
|
795
|
-
...diff
|
|
796
|
-
};
|
|
797
|
-
}
|
|
798
|
-
result[key] = fixed;
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
return result;
|
|
802
|
-
}
|
|
803
|
-
export { createAnimations, disableAnimationProps };
|
|
804
|
-
//# sourceMappingURL=createAnimations.native.js.map
|