@tamagui/animations-motion 2.0.0-rc.3 → 2.0.0-rc.30
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 +142 -139
- package/dist/cjs/createAnimations.native.js +203 -155
- package/dist/cjs/createAnimations.native.js.map +1 -1
- package/dist/cjs/index.js +12 -9
- package/dist/esm/createAnimations.mjs +142 -140
- package/dist/esm/createAnimations.mjs.map +1 -1
- package/dist/esm/createAnimations.native.js +203 -156
- 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/package.json +9 -12
- package/src/createAnimations.tsx +379 -343
- package/types/createAnimations.d.ts +2 -1
- 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 -401
- package/dist/cjs/createAnimations.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 -405
- package/dist/esm/createAnimations.js.map +0 -6
- package/dist/esm/polyfill.js +0 -2
- package/dist/esm/polyfill.js.map +0 -6
|
@@ -31,7 +31,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
31
|
}), mod);
|
|
32
32
|
var createAnimations_exports = {};
|
|
33
33
|
__export(createAnimations_exports, {
|
|
34
|
-
createAnimations: () => createAnimations
|
|
34
|
+
createAnimations: () => createAnimations,
|
|
35
|
+
disableAnimationProps: () => disableAnimationProps
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(createAnimations_exports);
|
|
37
38
|
var import_animation_helpers = require("@tamagui/animation-helpers"),
|
|
@@ -40,36 +41,20 @@ var import_animation_helpers = require("@tamagui/animation-helpers"),
|
|
|
40
41
|
import_react = require("motion/react"),
|
|
41
42
|
import_react2 = __toESM(require("react"), 1),
|
|
42
43
|
import_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
isTimingBased = config.duration !== void 0 && config.damping === void 0 && config.stiffness === void 0 && config.mass === void 0;
|
|
50
|
-
animations[key] = {
|
|
51
|
-
type: isTimingBased ? "tween" : "spring",
|
|
52
|
-
...config,
|
|
53
|
-
// Convert duration/delay from ms to seconds for motion library
|
|
54
|
-
...(config.duration ? {
|
|
55
|
-
duration: config.duration / 1e3
|
|
56
|
-
} : null),
|
|
57
|
-
...(config.delay ? {
|
|
58
|
-
delay: config.delay / 1e3
|
|
59
|
-
} : null)
|
|
60
|
-
};
|
|
61
|
-
}
|
|
44
|
+
const isServer = typeof window > "u";
|
|
45
|
+
function useAnimateSSRSafe() {
|
|
46
|
+
return isServer ? [(0, import_react2.useRef)(null), () => {}] : (0, import_react.useAnimate)();
|
|
47
|
+
}
|
|
48
|
+
const MotionValueStrategy = /* @__PURE__ */new WeakMap();
|
|
49
|
+
function createAnimations(animations) {
|
|
62
50
|
let isHydratingGlobal;
|
|
63
51
|
const hydratingComponents = /* @__PURE__ */new Set();
|
|
64
52
|
return {
|
|
65
|
-
// this is only used by Sheet basically for now to pass result of useAnimatedStyle to
|
|
66
53
|
View: MotionView,
|
|
67
54
|
Text: MotionText,
|
|
68
55
|
isReactNative: !1,
|
|
69
|
-
supportsCSS: !0,
|
|
70
56
|
inputStyle: "css",
|
|
71
57
|
outputStyle: "inline",
|
|
72
|
-
needsWebStyles: !0,
|
|
73
58
|
avoidReRenders: !0,
|
|
74
59
|
animations,
|
|
75
60
|
usePresence: import_use_presence.usePresence,
|
|
@@ -93,46 +78,62 @@ function createAnimations(animationsProp) {
|
|
|
93
78
|
isEntering = !!componentState.unmounted,
|
|
94
79
|
isExiting = presence?.[0] === !1,
|
|
95
80
|
sendExitComplete = presence?.[1],
|
|
96
|
-
|
|
97
|
-
|
|
81
|
+
refs = (0, import_react2.useRef)(null);
|
|
82
|
+
refs.current || (refs.current = {
|
|
83
|
+
isFirstRender: !0,
|
|
84
|
+
lastDoAnimate: null,
|
|
85
|
+
lastDontAnimate: null,
|
|
86
|
+
controls: null,
|
|
87
|
+
lastAnimateAt: 0,
|
|
88
|
+
disposed: !1,
|
|
89
|
+
wasExiting: !1,
|
|
90
|
+
isExiting: !1,
|
|
91
|
+
sendExitComplete: void 0,
|
|
92
|
+
animationState: "default",
|
|
93
|
+
frozenExitTarget: null,
|
|
94
|
+
exitCompleteScheduled: !1,
|
|
95
|
+
wasEntering: !1
|
|
96
|
+
});
|
|
97
|
+
const justFinishedEntering = refs.current.wasEntering && !isEntering;
|
|
98
98
|
(0, import_react2.useEffect)(() => {
|
|
99
|
-
|
|
99
|
+
refs.current.wasEntering = isEntering;
|
|
100
100
|
});
|
|
101
101
|
const animationState = isExiting ? "exit" : isMounting || justFinishedEntering ? "enter" : "default",
|
|
102
102
|
disableAnimation = isComponentHydrating || isMounting || !animationKey,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
{
|
|
103
|
+
[scope, animate] = useAnimateSSRSafe();
|
|
104
|
+
refs.current.isExiting = isExiting, refs.current.sendExitComplete = sendExitComplete, refs.current.animationState = animationState;
|
|
105
|
+
const justStartedExiting = isExiting && !refs.current.wasExiting,
|
|
106
|
+
justStoppedExiting = !isExiting && refs.current.wasExiting;
|
|
107
|
+
(justStartedExiting || justStoppedExiting) && (refs.current.frozenExitTarget = null, refs.current.exitCompleteScheduled = !1), (0, import_react2.useEffect)(() => {
|
|
108
|
+
refs.current.wasExiting = isExiting;
|
|
109
|
+
});
|
|
110
|
+
const {
|
|
112
111
|
dontAnimate = {},
|
|
113
112
|
doAnimate,
|
|
114
113
|
animationOptions
|
|
115
|
-
} =
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
disposed = (0, import_react2.useRef)(!1),
|
|
120
|
-
[firstRenderStyle] = (0, import_react2.useState)(style),
|
|
121
|
-
lastDontAnimate = (0, import_react2.useRef)(firstRenderStyle),
|
|
122
|
-
[isHydrating, setIsHydrating] = (0, import_react2.useState)(isHydratingGlobal);
|
|
114
|
+
} = getMotionAnimatedProps(props, style, disableAnimation, animationState),
|
|
115
|
+
[firstRenderStyle] = (0, import_react2.useState)(style);
|
|
116
|
+
refs.current.isFirstRender && (refs.current.lastDontAnimate = firstRenderStyle);
|
|
117
|
+
const [isHydrating, setIsHydrating] = (0, import_react2.useState)(isHydratingGlobal);
|
|
123
118
|
(0, import_react2.useLayoutEffect)(() => (isHydratingGlobal && hydratingComponents.add(() => {
|
|
124
119
|
setIsHydrating(!1);
|
|
125
120
|
}), () => {
|
|
126
|
-
|
|
121
|
+
refs.current.disposed = !0;
|
|
127
122
|
}), []);
|
|
128
123
|
const flushAnimation = ({
|
|
129
|
-
doAnimate:
|
|
130
|
-
animationOptions:
|
|
124
|
+
doAnimate: doAnimateRaw = {},
|
|
125
|
+
animationOptions: passedOptions = {},
|
|
131
126
|
dontAnimate: dontAnimate2
|
|
132
127
|
}) => {
|
|
128
|
+
let startedControls = null;
|
|
129
|
+
const isCurrentlyExiting = refs.current.isExiting,
|
|
130
|
+
currentSendExitComplete = refs.current.sendExitComplete;
|
|
131
|
+
let doAnimate2 = doAnimateRaw;
|
|
132
|
+
isCurrentlyExiting && refs.current.frozenExitTarget && (doAnimate2 = refs.current.frozenExitTarget);
|
|
133
|
+
const animationOptions2 = isCurrentlyExiting && currentSendExitComplete ? getAnimationOptions(props.transition ?? null, "exit") : passedOptions;
|
|
133
134
|
try {
|
|
134
135
|
const node = stateRef.current.host;
|
|
135
|
-
if (
|
|
136
|
+
if (refs.current.isFirstRender && (refs.current.lastDontAnimate = null, refs.current.lastDoAnimate = null), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && (console.groupCollapsed(`[motion] animate (${JSON.stringify(getDiff(refs.current.lastDoAnimate, doAnimate2), null, 2)})`), console.info({
|
|
136
137
|
props,
|
|
137
138
|
componentState,
|
|
138
139
|
doAnimate: doAnimate2,
|
|
@@ -140,105 +141,82 @@ function createAnimations(animationsProp) {
|
|
|
140
141
|
animationOptions: animationOptions2,
|
|
141
142
|
animationProps,
|
|
142
143
|
lastDoAnimate: {
|
|
143
|
-
...
|
|
144
|
+
...refs.current.lastDoAnimate
|
|
144
145
|
},
|
|
145
146
|
lastDontAnimate: {
|
|
146
|
-
...
|
|
147
|
+
...refs.current.lastDontAnimate
|
|
147
148
|
},
|
|
148
149
|
isExiting,
|
|
149
150
|
style,
|
|
150
151
|
node
|
|
151
152
|
}), console.groupCollapsed("trace >"), console.trace(), console.groupEnd(), console.groupEnd()), !(node instanceof HTMLElement)) return;
|
|
152
|
-
const prevDont =
|
|
153
|
+
const prevDont = refs.current.lastDontAnimate;
|
|
153
154
|
if (dontAnimate2) if (prevDont) {
|
|
154
155
|
removeRemovedStyles(prevDont, dontAnimate2, node, doAnimate2);
|
|
155
156
|
const changed = getDiff(prevDont, dontAnimate2);
|
|
156
157
|
changed && Object.assign(node.style, changed);
|
|
157
158
|
} else Object.assign(node.style, dontAnimate2);
|
|
158
159
|
if (doAnimate2) {
|
|
159
|
-
if (prevDont)
|
|
160
|
-
|
|
161
|
-
for (const key in prevDont) key in doAnimate2 && (node.style[key] = prevDont[key], movedToAnimate[key] = prevDont[key], lastDoAnimate.current && (lastDoAnimate.current[key] = prevDont[key]));
|
|
162
|
-
Object.keys(movedToAnimate).length > 0 && animate(scope.current, {
|
|
163
|
-
...movedToAnimate
|
|
164
|
-
}, {
|
|
165
|
-
duration: 0
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
const lastAnimated = lastDoAnimate.current;
|
|
160
|
+
if (prevDont) for (const key in prevDont) key in doAnimate2 && (node.style[key] = prevDont[key], refs.current.lastDoAnimate && (refs.current.lastDoAnimate[key] = prevDont[key]));
|
|
161
|
+
const lastAnimated = refs.current.lastDoAnimate;
|
|
169
162
|
lastAnimated && removeRemovedStyles(lastAnimated, doAnimate2, node, dontAnimate2);
|
|
170
|
-
const diff = getDiff(
|
|
163
|
+
const diff = getDiff(refs.current.lastDoAnimate, doAnimate2);
|
|
171
164
|
if (diff) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
currentY = Number.parseFloat(matrixMatch[2]),
|
|
185
|
-
keyframeDiff = {
|
|
186
|
-
...diff,
|
|
187
|
-
transform: [`translateX(${currentX}px) translateY(${currentY}px)`, targetTransform]
|
|
188
|
-
};
|
|
189
|
-
controls.current = animate(scope.current, keyframeDiff, animationOptions2), lastAnimateAt.current = Date.now(), lastDontAnimate.current = dontAnimate2 ? {
|
|
190
|
-
...dontAnimate2
|
|
191
|
-
} : {}, lastDoAnimate.current = doAnimate2 ? {
|
|
192
|
-
...doAnimate2
|
|
193
|
-
} : {};
|
|
194
|
-
return;
|
|
165
|
+
isCurrentlyExiting && !refs.current.frozenExitTarget && (refs.current.frozenExitTarget = {
|
|
166
|
+
...doAnimate2
|
|
167
|
+
});
|
|
168
|
+
const isPopperPosition = node.hasAttribute("data-popper-animate-position");
|
|
169
|
+
let midFlightValues = null;
|
|
170
|
+
if (refs.current.controls) {
|
|
171
|
+
try {
|
|
172
|
+
const computed = getComputedStyle(node);
|
|
173
|
+
midFlightValues = {};
|
|
174
|
+
for (const key in diff) {
|
|
175
|
+
const val = computed[key];
|
|
176
|
+
val !== void 0 && val !== "" && (midFlightValues[key] = val);
|
|
195
177
|
}
|
|
178
|
+
} catch {}
|
|
179
|
+
if (isCurrentlyExiting && refs.current.controls.stop(), midFlightValues) for (const key in midFlightValues) node.style[key] = midFlightValues[key];
|
|
180
|
+
if (isPopperPosition) {
|
|
181
|
+
const anims = node.getAnimations();
|
|
182
|
+
for (const anim of anims) anim.cancel();
|
|
196
183
|
}
|
|
197
184
|
}
|
|
198
|
-
const fixedDiff = fixTransparentColors(
|
|
199
|
-
|
|
200
|
-
}, lastDoAnimate.current);
|
|
201
|
-
controls.current = animate(scope.current, fixedDiff, animationOptions2), lastAnimateAt.current = Date.now();
|
|
185
|
+
const fixedDiff = fixTransparentColors(diff, refs.current.lastDoAnimate, doAnimate2);
|
|
186
|
+
midFlightValues?.transform && fixedDiff.transform && (fixedDiff.transform = [midFlightValues.transform, fixedDiff.transform]), startedControls = animate(scope.current, fixedDiff, animationOptions2), refs.current.controls = startedControls, refs.current.lastAnimateAt = Date.now();
|
|
202
187
|
}
|
|
203
188
|
}
|
|
204
|
-
|
|
189
|
+
refs.current.lastDontAnimate = dontAnimate2 ? {
|
|
205
190
|
...dontAnimate2
|
|
206
|
-
} : {},
|
|
191
|
+
} : {}, refs.current.lastDoAnimate = doAnimate2 ? {
|
|
207
192
|
...doAnimate2
|
|
208
193
|
} : {};
|
|
209
194
|
} finally {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
})
|
|
195
|
+
isCurrentlyExiting && currentSendExitComplete && (startedControls ? (refs.current.exitCompleteScheduled = !0, startedControls.finished.then(() => {
|
|
196
|
+
refs.current.isExiting && currentSendExitComplete();
|
|
197
|
+
}).catch(() => {
|
|
198
|
+
refs.current.isExiting && currentSendExitComplete();
|
|
199
|
+
})) : refs.current.exitCompleteScheduled || currentSendExitComplete());
|
|
213
200
|
}
|
|
214
201
|
};
|
|
215
|
-
return useStyleEmitter?.(nextStyle => {
|
|
216
|
-
const animationProps2 = getMotionAnimatedProps(props, nextStyle, disableAnimation, animationState);
|
|
202
|
+
return useStyleEmitter?.((nextStyle, effectiveTransition) => {
|
|
203
|
+
const animationProps2 = getMotionAnimatedProps(props, nextStyle, disableAnimation, refs.current.animationState, effectiveTransition);
|
|
217
204
|
flushAnimation(animationProps2);
|
|
218
205
|
}), (0, import_web.useIsomorphicLayoutEffect)(() => {
|
|
219
|
-
if (
|
|
220
|
-
if (
|
|
221
|
-
|
|
222
|
-
node instanceof HTMLElement && (dontAnimate && (Object.assign(node.style, dontAnimate), animate(scope.current, {
|
|
223
|
-
...dontAnimate
|
|
224
|
-
}, {
|
|
225
|
-
duration: 0
|
|
226
|
-
})), doAnimate && Object.keys(doAnimate).length > 0 ? (lastDoAnimate.current = {
|
|
227
|
-
...doAnimate
|
|
228
|
-
}, animate(scope.current, {
|
|
206
|
+
if (refs.current.isFirstRender) {
|
|
207
|
+
if (refs.current.isFirstRender = !1, isHydrating) {
|
|
208
|
+
doAnimate && Object.keys(doAnimate).length > 0 ? refs.current.lastDoAnimate = {
|
|
229
209
|
...doAnimate
|
|
230
|
-
}
|
|
231
|
-
duration: 0
|
|
232
|
-
})) : lastDoAnimate.current = dontAnimate ? {
|
|
210
|
+
} : refs.current.lastDoAnimate = dontAnimate ? {
|
|
233
211
|
...dontAnimate
|
|
234
|
-
} : {}
|
|
212
|
+
} : {}, refs.current.lastDontAnimate = dontAnimate ? {
|
|
235
213
|
...dontAnimate
|
|
236
|
-
} : {},
|
|
214
|
+
} : {}, refs.current.lastAnimateAt = Date.now();
|
|
237
215
|
return;
|
|
238
216
|
}
|
|
239
|
-
|
|
217
|
+
refs.current.lastDontAnimate = dontAnimate ? {
|
|
240
218
|
...dontAnimate
|
|
241
|
-
} : {},
|
|
219
|
+
} : {}, refs.current.lastDoAnimate = doAnimate ? {
|
|
242
220
|
...doAnimate
|
|
243
221
|
} : {};
|
|
244
222
|
return;
|
|
@@ -248,18 +226,16 @@ function createAnimations(animationsProp) {
|
|
|
248
226
|
dontAnimate,
|
|
249
227
|
animationOptions
|
|
250
228
|
});
|
|
251
|
-
}, [
|
|
229
|
+
}, [style, isExiting, disableAnimation]), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && (console.groupCollapsed("[motion] render"), console.info({
|
|
252
230
|
style,
|
|
253
231
|
doAnimate,
|
|
254
232
|
dontAnimate,
|
|
255
|
-
styleKey,
|
|
256
233
|
scope,
|
|
257
234
|
animationOptions,
|
|
258
235
|
isExiting,
|
|
259
|
-
isFirstRender:
|
|
236
|
+
isFirstRender: refs.current.isFirstRender,
|
|
260
237
|
animationProps
|
|
261
238
|
}), console.groupEnd()), {
|
|
262
|
-
// we never change this, after first render on
|
|
263
239
|
style: firstRenderStyle,
|
|
264
240
|
ref: scope,
|
|
265
241
|
render: "div"
|
|
@@ -308,11 +284,11 @@ function createAnimations(animationsProp) {
|
|
|
308
284
|
}), []);
|
|
309
285
|
}
|
|
310
286
|
};
|
|
311
|
-
function getMotionAnimatedProps(props, style, disable, animationState = "default") {
|
|
287
|
+
function getMotionAnimatedProps(props, style, disable, animationState = "default", transitionOverride) {
|
|
312
288
|
if (disable) return {
|
|
313
289
|
dontAnimate: style
|
|
314
290
|
};
|
|
315
|
-
const animationOptions =
|
|
291
|
+
const animationOptions = getAnimationOptions(transitionOverride ?? props.transition ?? null, animationState);
|
|
316
292
|
let dontAnimate, doAnimate;
|
|
317
293
|
const animateOnly = props.animateOnly;
|
|
318
294
|
for (const key in style) {
|
|
@@ -325,34 +301,54 @@ function createAnimations(animationsProp) {
|
|
|
325
301
|
animationOptions
|
|
326
302
|
};
|
|
327
303
|
}
|
|
328
|
-
function
|
|
329
|
-
const normalized = (0, import_animation_helpers.normalizeTransition)(transitionProp)
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
const
|
|
333
|
-
|
|
304
|
+
function getAnimationOptions(transitionProp, animationState = "default") {
|
|
305
|
+
const normalized = (0, import_animation_helpers.normalizeTransition)(transitionProp);
|
|
306
|
+
let effectiveKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState);
|
|
307
|
+
!effectiveKey && animationState === "default" && (effectiveKey = normalized.enter || normalized.exit || null);
|
|
308
|
+
const globalConfigOverride = normalized.config ? {
|
|
309
|
+
...normalized.config
|
|
310
|
+
} : void 0;
|
|
311
|
+
if (!effectiveKey && Object.keys(normalized.properties).length === 0 && !globalConfigOverride) return {};
|
|
312
|
+
const defaultConfig = effectiveKey ? withInferredType(animations[effectiveKey]) : null,
|
|
313
|
+
delay = normalized.delay,
|
|
334
314
|
result = {};
|
|
335
|
-
defaultConfig && (result.
|
|
315
|
+
defaultConfig && Object.assign(result, defaultConfig), globalConfigOverride && (Object.assign(result, globalConfigOverride), result.type === void 0 && result.duration !== void 0 && result.damping === void 0 && result.stiffness === void 0 && result.mass === void 0 && (result.type = "tween")), delay && (result.delay = delay), (defaultConfig || globalConfigOverride || delay) && (result.default = {
|
|
336
316
|
...defaultConfig,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
317
|
+
...globalConfigOverride,
|
|
318
|
+
...(delay ? {
|
|
319
|
+
delay
|
|
320
|
+
} : null)
|
|
321
|
+
});
|
|
322
|
+
for (const [propName, animationNameOrConfig] of Object.entries(normalized.properties)) if (typeof animationNameOrConfig == "string") result[propName] = withInferredType(animations[animationNameOrConfig]);else if (animationNameOrConfig && typeof animationNameOrConfig == "object") {
|
|
323
|
+
const baseConfig = animationNameOrConfig.type ? withInferredType(animations[animationNameOrConfig.type]) : defaultConfig;
|
|
341
324
|
result[propName] = {
|
|
342
325
|
...baseConfig,
|
|
343
326
|
...animationNameOrConfig
|
|
344
327
|
};
|
|
345
328
|
}
|
|
329
|
+
convertMsToS(result), convertMsToS(result.default);
|
|
330
|
+
for (const key in result) key !== "default" && typeof result[key] == "object" && convertMsToS(result[key]);
|
|
346
331
|
return result;
|
|
347
332
|
}
|
|
348
333
|
}
|
|
334
|
+
function withInferredType(config) {
|
|
335
|
+
return config ? {
|
|
336
|
+
type: config.duration !== void 0 && config.damping === void 0 && config.stiffness === void 0 && config.mass === void 0 ? "tween" : "spring",
|
|
337
|
+
...config
|
|
338
|
+
} : {
|
|
339
|
+
type: "spring"
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function convertMsToS(config) {
|
|
343
|
+
config && (typeof config.delay == "number" && (config.delay = config.delay / 1e3), typeof config.duration == "number" && (config.type === "tween" || config.type === void 0 && config.damping === void 0 && config.stiffness === void 0 && config.mass === void 0) && (config.duration = config.duration / 1e3));
|
|
344
|
+
}
|
|
349
345
|
function removeRemovedStyles(prev, next, node, dontClearIfIn) {
|
|
350
346
|
for (const key in prev) if (!(key in next)) {
|
|
351
347
|
if (dontClearIfIn && key in dontClearIfIn) continue;
|
|
352
348
|
node.style[key] = "";
|
|
353
349
|
}
|
|
354
350
|
}
|
|
355
|
-
const disableAnimationProps = /* @__PURE__ */new Set(["alignContent", "alignItems", "
|
|
351
|
+
const disableAnimationProps = /* @__PURE__ */new Set(["alignContent", "alignItems", "boxSizing", "contain", "containerType", "display", "flexBasis", "flexDirection", "fontFamily", "justifyContent", "overflow", "overflowX", "overflowY", "pointerEvents", "position", "textWrap", "userSelect"]),
|
|
356
352
|
MotionView = createMotionView("div"),
|
|
357
353
|
MotionText = createMotionView("span");
|
|
358
354
|
function createMotionView(defaultTag) {
|
|
@@ -365,7 +361,7 @@ function createMotionView(defaultTag) {
|
|
|
365
361
|
style,
|
|
366
362
|
...propsRest
|
|
367
363
|
} = propsIn,
|
|
368
|
-
[scope, animate] = (
|
|
364
|
+
[scope, animate] = useAnimateSSRSafe(),
|
|
369
365
|
hostRef = (0, import_react2.useRef)(null),
|
|
370
366
|
composedRefs = (0, import_web.useComposedRefs)(forwardedRef, ref, hostRef, scope),
|
|
371
367
|
stateRef = (0, import_react2.useRef)(null);
|
|
@@ -376,14 +372,18 @@ function createMotionView(defaultTag) {
|
|
|
376
372
|
});
|
|
377
373
|
const [_, state] = (0, import_web.useThemeWithState)({}),
|
|
378
374
|
styles = Array.isArray(style) ? style : [style],
|
|
379
|
-
[animatedStyle, nonAnimatedStyles] =
|
|
375
|
+
[animatedStyle, nonAnimatedStyles] = (() => {
|
|
376
|
+
let animatedStyle2;
|
|
377
|
+
const nonAnimatedStyles2 = [];
|
|
378
|
+
for (const style2 of styles) style2.getStyle ? animatedStyle2 = style2 : nonAnimatedStyles2.push(style2);
|
|
379
|
+
return [animatedStyle2, nonAnimatedStyles2];
|
|
380
|
+
})();
|
|
380
381
|
function getProps(props2) {
|
|
381
382
|
const out = (0, import_web.getSplitStyles)(props2, isText ? import_web.Text.staticConfig : import_web.View.staticConfig, state?.theme, state?.name, {
|
|
382
383
|
unmounted: !1
|
|
383
384
|
}, {
|
|
384
385
|
isAnimated: !1,
|
|
385
386
|
noClass: !0,
|
|
386
|
-
// noMergeStyle: true,
|
|
387
387
|
resolveValues: "auto"
|
|
388
388
|
});
|
|
389
389
|
return out ? (out.viewProps.style && ((0, import_web.fixStyles)(out.viewProps.style), (0, import_web.styleToCSS)(out.viewProps.style)), out.viewProps) : {};
|
|
@@ -421,7 +421,7 @@ function createMotionView(defaultTag) {
|
|
|
421
421
|
ref: composedRefs
|
|
422
422
|
});
|
|
423
423
|
});
|
|
424
|
-
return Component.
|
|
424
|
+
return Component.acceptRenderProp = !0, Component;
|
|
425
425
|
}
|
|
426
426
|
function getDiff(previous, next) {
|
|
427
427
|
if (!previous) return next;
|
|
@@ -429,14 +429,17 @@ function getDiff(previous, next) {
|
|
|
429
429
|
for (const key in next) next[key] !== previous[key] && (diff ||= {}, diff[key] = next[key]);
|
|
430
430
|
return diff;
|
|
431
431
|
}
|
|
432
|
-
function fixTransparentColors(diff, previous) {
|
|
432
|
+
function fixTransparentColors(diff, previous, next) {
|
|
433
433
|
let result = diff;
|
|
434
434
|
for (const key in diff) if (diff[key] === "transparent") {
|
|
435
|
-
const prev = previous?.[key];
|
|
436
435
|
let fixed = "rgba(0, 0, 0, 0)";
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
rgbaMatch
|
|
436
|
+
const candidates = [previous?.[key], next?.[key]];
|
|
437
|
+
for (const candidate of candidates) if (typeof candidate == "string" && candidate !== "transparent") {
|
|
438
|
+
const rgbaMatch = candidate.match(/^rgba?\(([^,]+),\s*([^,]+),\s*([^,)]+)/);
|
|
439
|
+
if (rgbaMatch) {
|
|
440
|
+
fixed = `rgba(${rgbaMatch[1]}, ${rgbaMatch[2]}, ${rgbaMatch[3]}, 0)`;
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
440
443
|
}
|
|
441
444
|
result === diff && (result = {
|
|
442
445
|
...diff
|