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