@tamagui/animations-css 2.7.7 → 3.0.0-beta.643.1
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/animated-number.cjs +195 -0
- package/dist/cjs/animated-number.native.cjs +292 -0
- package/dist/cjs/animated-number.native.js +294 -0
- package/dist/cjs/animated-number.native.js.map +1 -0
- package/dist/cjs/createAnimations.cjs +359 -416
- package/dist/cjs/createAnimations.native.cjs +472 -0
- package/dist/cjs/createAnimations.native.js +446 -510
- package/dist/cjs/createAnimations.native.js.map +1 -1
- package/dist/cjs/index.cjs +10 -11
- package/dist/cjs/index.native.cjs +21 -0
- package/dist/cjs/index.native.js +10 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/animated-number.mjs +164 -0
- package/dist/esm/animated-number.mjs.map +1 -0
- package/dist/esm/animated-number.native.js +259 -0
- package/dist/esm/animated-number.native.js.map +1 -0
- package/dist/esm/createAnimations.mjs +344 -391
- package/dist/esm/createAnimations.mjs.map +1 -1
- package/dist/esm/createAnimations.native.js +430 -485
- package/dist/esm/createAnimations.native.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/index.native.js +1 -2
- package/package.json +16 -7
- package/src/animated-number.tsx +262 -0
- package/src/createAnimations.tsx +305 -501
- package/types/animated-number.d.ts +19 -0
- package/types/animated-number.d.ts.map +11 -0
- package/types/createAnimations.d.ts.map +2 -2
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: () => from[key],
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
28
|
+
}) : target, mod));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var createAnimations_exports = {};
|
|
31
|
+
__export(createAnimations_exports, { createAnimations: () => createAnimations });
|
|
32
|
+
module.exports = __toCommonJS(createAnimations_exports);
|
|
33
|
+
var import_animation_helpers = require("@tamagui/animation-helpers");
|
|
34
|
+
var import_constants = require("@tamagui/constants");
|
|
35
|
+
var import_use_presence = require("@tamagui/use-presence");
|
|
36
|
+
var import_web = require("@tamagui/web");
|
|
37
|
+
var import_react = __toESM(require("react"), 1);
|
|
38
|
+
var import_animated_number = require("./animated-number.native.js");
|
|
39
|
+
var hasRAF = typeof requestAnimationFrame !== "undefined";
|
|
40
|
+
function waitForAnimations(node) {
|
|
41
|
+
if (typeof node.getAnimations !== "function") {
|
|
42
|
+
return Promise.resolve(true);
|
|
43
|
+
}
|
|
44
|
+
return new Promise(function(resolve) {
|
|
45
|
+
var check = function() {
|
|
46
|
+
var animations = node.getAnimations();
|
|
47
|
+
if (animations.length === 0) {
|
|
48
|
+
resolve(true);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
Promise.all(animations.map(function(a) {
|
|
52
|
+
return a.finished;
|
|
53
|
+
})).then(function() {
|
|
54
|
+
return resolve(true);
|
|
55
|
+
}).catch(function() {
|
|
56
|
+
var remaining = node.getAnimations();
|
|
57
|
+
if (remaining.some(function(a) {
|
|
58
|
+
return a.playState === "running" || a.pending;
|
|
59
|
+
})) {
|
|
60
|
+
check();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
resolve(false);
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
if (hasRAF) {
|
|
67
|
+
requestAnimationFrame(check);
|
|
68
|
+
} else {
|
|
69
|
+
check();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
var DURATION_REGEX = /(\d+(?:\.\d+)?)\s*(?:ms|s(?!tiffness))/;
|
|
74
|
+
function applyDurationOverride(animation, durationMs) {
|
|
75
|
+
var replaced = animation.replace(DURATION_REGEX, `${durationMs}ms`);
|
|
76
|
+
return replaced === animation ? `${durationMs}ms ${animation}` : replaced;
|
|
77
|
+
}
|
|
78
|
+
var CSS_TRANSFORM_PROPERTIES = {
|
|
79
|
+
transform: [
|
|
80
|
+
"translate",
|
|
81
|
+
"scale",
|
|
82
|
+
"rotate",
|
|
83
|
+
"transform"
|
|
84
|
+
],
|
|
85
|
+
x: ["translate"],
|
|
86
|
+
y: ["translate"],
|
|
87
|
+
scale: ["scale"],
|
|
88
|
+
scaleX: ["scale"],
|
|
89
|
+
scaleY: ["scale"],
|
|
90
|
+
rotate: ["rotate"],
|
|
91
|
+
rotateX: ["transform"],
|
|
92
|
+
rotateY: ["transform"],
|
|
93
|
+
rotateZ: ["transform"],
|
|
94
|
+
skewX: ["transform"],
|
|
95
|
+
skewY: ["transform"]
|
|
96
|
+
};
|
|
97
|
+
var getCSSProperties = function(key) {
|
|
98
|
+
return CSS_TRANSFORM_PROPERTIES[key] || [key];
|
|
99
|
+
};
|
|
100
|
+
var hyphenatedPropertyCache = {};
|
|
101
|
+
var emptyProperties = [];
|
|
102
|
+
function hyphenateProperty(property) {
|
|
103
|
+
var _hyphenatedPropertyCache, _property;
|
|
104
|
+
if (property.startsWith("--")) return property;
|
|
105
|
+
return (_hyphenatedPropertyCache = hyphenatedPropertyCache)[_property = property] || (_hyphenatedPropertyCache[_property] = property.replace(/[A-Z]/g, function(letter) {
|
|
106
|
+
return `-${letter.toLowerCase()}`;
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
function getLifecycleCSSProperties(keys) {
|
|
110
|
+
if (!(keys === null || keys === void 0 ? void 0 : keys.size)) return emptyProperties;
|
|
111
|
+
var properties = /* @__PURE__ */ new Set();
|
|
112
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
113
|
+
try {
|
|
114
|
+
for (var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
115
|
+
var key = _step.value;
|
|
116
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
117
|
+
try {
|
|
118
|
+
for (var _iterator1 = getCSSProperties(key)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
119
|
+
var property = _step1.value;
|
|
120
|
+
properties.add(hyphenateProperty(property));
|
|
121
|
+
}
|
|
122
|
+
} catch (err) {
|
|
123
|
+
_didIteratorError1 = true;
|
|
124
|
+
_iteratorError1 = err;
|
|
125
|
+
} finally {
|
|
126
|
+
try {
|
|
127
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
128
|
+
_iterator1.return();
|
|
129
|
+
}
|
|
130
|
+
} finally {
|
|
131
|
+
if (_didIteratorError1) {
|
|
132
|
+
throw _iteratorError1;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} catch (err) {
|
|
138
|
+
_didIteratorError = true;
|
|
139
|
+
_iteratorError = err;
|
|
140
|
+
} finally {
|
|
141
|
+
try {
|
|
142
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
143
|
+
_iterator.return();
|
|
144
|
+
}
|
|
145
|
+
} finally {
|
|
146
|
+
if (_didIteratorError) {
|
|
147
|
+
throw _iteratorError;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return [...properties].sort();
|
|
152
|
+
}
|
|
153
|
+
function readComputedProperties(node, properties) {
|
|
154
|
+
var computed = getComputedStyle(node);
|
|
155
|
+
var values = {};
|
|
156
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
157
|
+
try {
|
|
158
|
+
for (var _iterator = properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
159
|
+
var property = _step.value;
|
|
160
|
+
var value = computed.getPropertyValue(property);
|
|
161
|
+
if (value) values[property] = value;
|
|
162
|
+
}
|
|
163
|
+
} catch (err) {
|
|
164
|
+
_didIteratorError = true;
|
|
165
|
+
_iteratorError = err;
|
|
166
|
+
} finally {
|
|
167
|
+
try {
|
|
168
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
169
|
+
_iterator.return();
|
|
170
|
+
}
|
|
171
|
+
} finally {
|
|
172
|
+
if (_didIteratorError) {
|
|
173
|
+
throw _iteratorError;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return values;
|
|
178
|
+
}
|
|
179
|
+
function applyCSSProperties(node, values) {
|
|
180
|
+
for (var property in values) {
|
|
181
|
+
node.style.setProperty(property, values[property]);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function clearCSSProperties(node, properties) {
|
|
185
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
186
|
+
try {
|
|
187
|
+
for (var _iterator = properties[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
188
|
+
var property = _step.value;
|
|
189
|
+
node.style.removeProperty(property);
|
|
190
|
+
}
|
|
191
|
+
} catch (err) {
|
|
192
|
+
_didIteratorError = true;
|
|
193
|
+
_iteratorError = err;
|
|
194
|
+
} finally {
|
|
195
|
+
try {
|
|
196
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
197
|
+
_iterator.return();
|
|
198
|
+
}
|
|
199
|
+
} finally {
|
|
200
|
+
if (_didIteratorError) {
|
|
201
|
+
throw _iteratorError;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function createAnimations(animations) {
|
|
207
|
+
return {
|
|
208
|
+
animations,
|
|
209
|
+
usePresence: import_use_presence.usePresence,
|
|
210
|
+
ResetPresence: import_use_presence.ResetPresence,
|
|
211
|
+
inputStyle: "css",
|
|
212
|
+
outputStyle: "css",
|
|
213
|
+
useAnimatedNumber: import_animated_number.useAnimatedNumber,
|
|
214
|
+
useAnimatedNumberReaction: import_animated_number.useAnimatedNumberReaction,
|
|
215
|
+
useAnimatedNumberStyle: import_animated_number.useAnimatedNumberStyle,
|
|
216
|
+
useAnimatedNumbersStyle: import_animated_number.useAnimatedNumbersStyle,
|
|
217
|
+
useAnimations: function(param) {
|
|
218
|
+
var { props, presence, style, componentState, stateRef, styleState, onTransition } = param;
|
|
219
|
+
var _styleState_programLifecycleStyleKeys;
|
|
220
|
+
var isHydrating = componentState.unmounted === true;
|
|
221
|
+
var isEntering = !!componentState.unmounted;
|
|
222
|
+
var isExiting = (presence === null || presence === void 0 ? void 0 : presence[0]) === false;
|
|
223
|
+
var sendExitComplete = presence === null || presence === void 0 ? void 0 : presence[1];
|
|
224
|
+
var onTransitionRef = import_react.default.useRef(onTransition);
|
|
225
|
+
onTransitionRef.current = onTransition;
|
|
226
|
+
var emit = function(phase, cause, finished) {
|
|
227
|
+
var _onTransitionRef_current;
|
|
228
|
+
(_onTransitionRef_current = onTransitionRef.current) === null || _onTransitionRef_current === void 0 ? void 0 : _onTransitionRef_current.call(onTransitionRef, phase === "end" ? {
|
|
229
|
+
phase,
|
|
230
|
+
cause,
|
|
231
|
+
finished
|
|
232
|
+
} : {
|
|
233
|
+
phase,
|
|
234
|
+
cause
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
var wasEnteringRef = import_react.default.useRef(isEntering);
|
|
238
|
+
var justFinishedEntering = wasEnteringRef.current && !isEntering;
|
|
239
|
+
import_react.default.useEffect(function() {
|
|
240
|
+
wasEnteringRef.current = isEntering;
|
|
241
|
+
});
|
|
242
|
+
var exitCycleIdRef = import_react.default.useRef(0);
|
|
243
|
+
var exitCompletedRef = import_react.default.useRef(false);
|
|
244
|
+
var wasExitingRef = import_react.default.useRef(false);
|
|
245
|
+
var sendExitCompleteRef = import_react.default.useRef(sendExitComplete);
|
|
246
|
+
var lastMountedStyleRef = import_react.default.useRef({});
|
|
247
|
+
sendExitCompleteRef.current = sendExitComplete;
|
|
248
|
+
var exitCSSProperties = getLifecycleCSSProperties(styleState === null || styleState === void 0 ? void 0 : (_styleState_programLifecycleStyleKeys = styleState.programLifecycleStyleKeys) === null || _styleState_programLifecycleStyleKeys === void 0 ? void 0 : _styleState_programLifecycleStyleKeys.exit);
|
|
249
|
+
var exitCSSPropertiesSignature = exitCSSProperties.join("\0");
|
|
250
|
+
var enterCycleIdRef = import_react.default.useRef(0);
|
|
251
|
+
var enterStartedRef = import_react.default.useRef(false);
|
|
252
|
+
var updateCycleIdRef = import_react.default.useRef(0);
|
|
253
|
+
var updateInFlightRef = import_react.default.useRef(false);
|
|
254
|
+
var prevUpdateSigRef = import_react.default.useRef(null);
|
|
255
|
+
var exitStartedRef = import_react.default.useRef(false);
|
|
256
|
+
var justStartedExiting = isExiting && !wasExitingRef.current;
|
|
257
|
+
var justStoppedExiting = !isExiting && wasExitingRef.current;
|
|
258
|
+
if (justStartedExiting) {
|
|
259
|
+
exitCycleIdRef.current++;
|
|
260
|
+
exitCompletedRef.current = false;
|
|
261
|
+
}
|
|
262
|
+
if (justStoppedExiting) {
|
|
263
|
+
exitCycleIdRef.current++;
|
|
264
|
+
}
|
|
265
|
+
import_react.default.useEffect(function() {
|
|
266
|
+
wasExitingRef.current = isExiting;
|
|
267
|
+
});
|
|
268
|
+
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
269
|
+
if (isExiting) return;
|
|
270
|
+
var host = stateRef.current.host;
|
|
271
|
+
if (!host || !exitCSSProperties.length) {
|
|
272
|
+
lastMountedStyleRef.current = {};
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
var node = host;
|
|
276
|
+
var capture = function() {
|
|
277
|
+
if (stateRef.current.host !== node || wasExitingRef.current) return;
|
|
278
|
+
lastMountedStyleRef.current = readComputedProperties(node, exitCSSProperties);
|
|
279
|
+
};
|
|
280
|
+
if (justFinishedEntering) {
|
|
281
|
+
void waitForAnimations(node).then(capture);
|
|
282
|
+
} else {
|
|
283
|
+
capture();
|
|
284
|
+
}
|
|
285
|
+
}, [
|
|
286
|
+
isExiting,
|
|
287
|
+
justFinishedEntering,
|
|
288
|
+
exitCSSPropertiesSignature
|
|
289
|
+
]);
|
|
290
|
+
var _styleState_effectiveTransition;
|
|
291
|
+
var effectiveTransition = (_styleState_effectiveTransition = styleState === null || styleState === void 0 ? void 0 : styleState.effectiveTransition) !== null && _styleState_effectiveTransition !== void 0 ? _styleState_effectiveTransition : props.transition;
|
|
292
|
+
var normalized = (0, import_animation_helpers.normalizeTransition)(effectiveTransition);
|
|
293
|
+
var animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default";
|
|
294
|
+
var effectiveAnimationKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState);
|
|
295
|
+
var defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null;
|
|
296
|
+
var animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized);
|
|
297
|
+
var hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null;
|
|
298
|
+
var hasPerPropertyConfigs = animatedProperties.length > 0;
|
|
299
|
+
var keys;
|
|
300
|
+
if (props.animateOnly) {
|
|
301
|
+
keys = props.animateOnly;
|
|
302
|
+
} else if (hasPerPropertyConfigs && !hasDefault) {
|
|
303
|
+
keys = animatedProperties;
|
|
304
|
+
} else if (hasPerPropertyConfigs && hasDefault) {
|
|
305
|
+
keys = ["all", ...animatedProperties];
|
|
306
|
+
} else {
|
|
307
|
+
keys = ["all"];
|
|
308
|
+
}
|
|
309
|
+
var transition;
|
|
310
|
+
var getTransition = function() {
|
|
311
|
+
var _normalized_config;
|
|
312
|
+
if (transition !== void 0) return transition;
|
|
313
|
+
var delay = normalized.delay ? ` ${normalized.delay}ms` : "";
|
|
314
|
+
var duration = (_normalized_config = normalized.config) === null || _normalized_config === void 0 ? void 0 : _normalized_config.duration;
|
|
315
|
+
transition = keys.flatMap(function(key) {
|
|
316
|
+
var propertyAnimation = normalized.properties[key];
|
|
317
|
+
var animation = defaultAnimation;
|
|
318
|
+
if (typeof propertyAnimation === "string") {
|
|
319
|
+
animation = animations[propertyAnimation];
|
|
320
|
+
} else if (propertyAnimation === null || propertyAnimation === void 0 ? void 0 : propertyAnimation.type) {
|
|
321
|
+
animation = animations[propertyAnimation.type];
|
|
322
|
+
}
|
|
323
|
+
if (animation && duration) {
|
|
324
|
+
animation = applyDurationOverride(animation, duration);
|
|
325
|
+
}
|
|
326
|
+
return animation ? getCSSProperties(key).map(function(property) {
|
|
327
|
+
return `${property} ${animation}${delay}`;
|
|
328
|
+
}) : [];
|
|
329
|
+
}).join(", ");
|
|
330
|
+
return transition;
|
|
331
|
+
};
|
|
332
|
+
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
333
|
+
var host = stateRef.current.host;
|
|
334
|
+
if (!sendExitComplete || !isExiting || !host) return;
|
|
335
|
+
var node = host;
|
|
336
|
+
var cycleId = exitCycleIdRef.current;
|
|
337
|
+
if (!exitStartedRef.current) {
|
|
338
|
+
exitStartedRef.current = true;
|
|
339
|
+
emit("start", "exit");
|
|
340
|
+
}
|
|
341
|
+
var completeExit = function() {
|
|
342
|
+
var finished = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
343
|
+
var _sendExitCompleteRef_current;
|
|
344
|
+
if (cycleId !== exitCycleIdRef.current) return;
|
|
345
|
+
if (exitCompletedRef.current) return;
|
|
346
|
+
exitCompletedRef.current = true;
|
|
347
|
+
if (exitStartedRef.current) {
|
|
348
|
+
exitStartedRef.current = false;
|
|
349
|
+
emit("end", "exit", finished);
|
|
350
|
+
}
|
|
351
|
+
(_sendExitCompleteRef_current = sendExitCompleteRef.current) === null || _sendExitCompleteRef_current === void 0 ? void 0 : _sendExitCompleteRef_current.call(sendExitCompleteRef);
|
|
352
|
+
};
|
|
353
|
+
if (keys.length === 0) {
|
|
354
|
+
completeExit();
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
var rafId;
|
|
358
|
+
var disposed = false;
|
|
359
|
+
var mountedStyle = lastMountedStyleRef.current;
|
|
360
|
+
var canRestart = exitCSSProperties.length > 0 && Object.keys(mountedStyle).length > 0;
|
|
361
|
+
var exitTarget;
|
|
362
|
+
if (canRestart) {
|
|
363
|
+
node.style.transition = "none";
|
|
364
|
+
exitTarget = readComputedProperties(node, exitCSSProperties);
|
|
365
|
+
applyCSSProperties(node, mountedStyle);
|
|
366
|
+
void node.offsetHeight;
|
|
367
|
+
rafId = requestAnimationFrame(function() {
|
|
368
|
+
if (cycleId !== exitCycleIdRef.current) return;
|
|
369
|
+
node.style.transition = getTransition();
|
|
370
|
+
void node.offsetHeight;
|
|
371
|
+
applyCSSProperties(node, exitTarget);
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
void waitForAnimations(node).then(function(finished) {
|
|
375
|
+
if (!disposed) completeExit(finished);
|
|
376
|
+
});
|
|
377
|
+
return function() {
|
|
378
|
+
disposed = true;
|
|
379
|
+
if (rafId !== void 0) cancelAnimationFrame(rafId);
|
|
380
|
+
clearCSSProperties(node, exitCSSProperties);
|
|
381
|
+
node.style.transition = "";
|
|
382
|
+
};
|
|
383
|
+
}, [isExiting, exitCSSPropertiesSignature]);
|
|
384
|
+
var styleSignature = onTransition ? (function() {
|
|
385
|
+
var { transition: _t, ...rest } = style;
|
|
386
|
+
var _styleState_classNames;
|
|
387
|
+
return `${JSON.stringify((_styleState_classNames = styleState === null || styleState === void 0 ? void 0 : styleState.classNames) !== null && _styleState_classNames !== void 0 ? _styleState_classNames : null)}|${JSON.stringify(rest)}`;
|
|
388
|
+
})() : "";
|
|
389
|
+
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
390
|
+
var host = stateRef.current.host;
|
|
391
|
+
if (!onTransitionRef.current || isExiting || !justFinishedEntering || !host) {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
var node = host;
|
|
395
|
+
var cycleId = ++enterCycleIdRef.current;
|
|
396
|
+
enterStartedRef.current = true;
|
|
397
|
+
emit("start", "enter");
|
|
398
|
+
void waitForAnimations(node).then(function(finished) {
|
|
399
|
+
if (cycleId !== enterCycleIdRef.current || !enterStartedRef.current) return;
|
|
400
|
+
enterStartedRef.current = false;
|
|
401
|
+
emit("end", "enter", finished);
|
|
402
|
+
});
|
|
403
|
+
}, [justFinishedEntering, isExiting]);
|
|
404
|
+
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
405
|
+
var host = stateRef.current.host;
|
|
406
|
+
if (!onTransitionRef.current || isEntering || justFinishedEntering || isExiting || !host) {
|
|
407
|
+
prevUpdateSigRef.current = styleSignature;
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
if (prevUpdateSigRef.current === null) {
|
|
411
|
+
prevUpdateSigRef.current = styleSignature;
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
if (styleSignature === prevUpdateSigRef.current) return;
|
|
415
|
+
prevUpdateSigRef.current = styleSignature;
|
|
416
|
+
var node = host;
|
|
417
|
+
if (updateInFlightRef.current) {
|
|
418
|
+
emit("end", "update", false);
|
|
419
|
+
}
|
|
420
|
+
updateInFlightRef.current = true;
|
|
421
|
+
var cycleId = ++updateCycleIdRef.current;
|
|
422
|
+
emit("start", "update");
|
|
423
|
+
void waitForAnimations(node).then(function(finished) {
|
|
424
|
+
if (cycleId !== updateCycleIdRef.current) return;
|
|
425
|
+
updateInFlightRef.current = false;
|
|
426
|
+
emit("end", "update", finished);
|
|
427
|
+
});
|
|
428
|
+
}, [
|
|
429
|
+
styleSignature,
|
|
430
|
+
isEntering,
|
|
431
|
+
justFinishedEntering,
|
|
432
|
+
isExiting
|
|
433
|
+
]);
|
|
434
|
+
(0, import_constants.useIsomorphicLayoutEffect)(function() {
|
|
435
|
+
if (justStartedExiting && enterStartedRef.current) {
|
|
436
|
+
enterCycleIdRef.current++;
|
|
437
|
+
enterStartedRef.current = false;
|
|
438
|
+
emit("end", "enter", false);
|
|
439
|
+
}
|
|
440
|
+
if (justStoppedExiting && exitStartedRef.current && !exitCompletedRef.current) {
|
|
441
|
+
exitStartedRef.current = false;
|
|
442
|
+
emit("end", "exit", false);
|
|
443
|
+
}
|
|
444
|
+
}, [justStartedExiting, justStoppedExiting]);
|
|
445
|
+
if (isHydrating) {
|
|
446
|
+
return null;
|
|
447
|
+
}
|
|
448
|
+
if (!(0, import_animation_helpers.hasAnimation)(normalized)) {
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
if (Array.isArray(style.transform)) {
|
|
452
|
+
style.transform = (0, import_web.transformsToString)(style.transform);
|
|
453
|
+
}
|
|
454
|
+
style.transition = getTransition();
|
|
455
|
+
if (process.env.NODE_ENV === "development" && props["debug"] === "verbose") {
|
|
456
|
+
console.info("CSS animation", {
|
|
457
|
+
props,
|
|
458
|
+
animations,
|
|
459
|
+
normalized,
|
|
460
|
+
defaultAnimation,
|
|
461
|
+
style,
|
|
462
|
+
isEntering,
|
|
463
|
+
isExiting
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
return {
|
|
467
|
+
style,
|
|
468
|
+
className: isEntering ? "t_unmounted" : ""
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
}
|