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