@tamagui/animations-css 2.0.0-1768326993354 → 2.0.0-1768530912818
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 +20 -19
- package/dist/cjs/createAnimations.js +15 -15
- package/dist/cjs/createAnimations.js.map +2 -2
- package/dist/cjs/createAnimations.native.js +27 -21
- package/dist/cjs/createAnimations.native.js.map +1 -1
- package/dist/esm/createAnimations.js +19 -14
- package/dist/esm/createAnimations.js.map +1 -1
- package/dist/esm/createAnimations.mjs +19 -18
- package/dist/esm/createAnimations.mjs.map +1 -1
- package/dist/esm/createAnimations.native.js +26 -20
- package/dist/esm/createAnimations.native.js.map +1 -1
- package/package.json +7 -6
- package/src/createAnimations.tsx +55 -30
- package/types/createAnimations.d.ts.map +2 -2
|
@@ -34,7 +34,8 @@ __export(createAnimations_exports, {
|
|
|
34
34
|
createAnimations: () => createAnimations
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(createAnimations_exports);
|
|
37
|
-
var
|
|
37
|
+
var import_animation_helpers = require("@tamagui/animation-helpers"),
|
|
38
|
+
import_constants = require("@tamagui/constants"),
|
|
38
39
|
import_use_presence = require("@tamagui/use-presence"),
|
|
39
40
|
import_web = require("@tamagui/web"),
|
|
40
41
|
import_react = __toESM(require("react"), 1);
|
|
@@ -98,15 +99,16 @@ function createAnimations(animations) {
|
|
|
98
99
|
const isEntering = !!componentState.unmounted,
|
|
99
100
|
isExiting = presence?.[0] === !1,
|
|
100
101
|
sendExitComplete = presence?.[1],
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
normalized = (0, import_animation_helpers.normalizeTransition)(props.transition),
|
|
103
|
+
defaultAnimation = normalized.default ? animations[normalized.default] : null,
|
|
104
|
+
animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized),
|
|
105
|
+
keys = animatedProperties.length > 0 ? animatedProperties : props.animateOnly ?? ["all"];
|
|
104
106
|
if ((0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
105
107
|
const host = stateRef.current.host;
|
|
106
108
|
if (!sendExitComplete || !isExiting || !host) return;
|
|
107
109
|
const node = host,
|
|
108
|
-
animationDuration =
|
|
109
|
-
delay =
|
|
110
|
+
animationDuration = defaultAnimation ? extractDuration(defaultAnimation) : 200,
|
|
111
|
+
delay = normalized.delay ?? 0,
|
|
110
112
|
fallbackTimeout = animationDuration + delay,
|
|
111
113
|
timeoutId = setTimeout(() => {
|
|
112
114
|
sendExitComplete?.();
|
|
@@ -117,26 +119,25 @@ function createAnimations(animations) {
|
|
|
117
119
|
return node.addEventListener("transitionend", onFinishAnimation), node.addEventListener("transitioncancel", onFinishAnimation), () => {
|
|
118
120
|
clearTimeout(timeoutId), node.removeEventListener("transitionend", onFinishAnimation), node.removeEventListener("transitioncancel", onFinishAnimation);
|
|
119
121
|
};
|
|
120
|
-
}, [sendExitComplete, isExiting]),
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
return process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("CSS animation", {
|
|
122
|
+
}, [sendExitComplete, isExiting]), !(0, import_animation_helpers.hasAnimation)(normalized)) return null;
|
|
123
|
+
Array.isArray(style.transform) && (style.transform = (0, import_web.transformsToString)(style.transform));
|
|
124
|
+
const delayStr = normalized.delay ? ` ${normalized.delay}ms` : "";
|
|
125
|
+
return style.transition = keys.map(key => {
|
|
126
|
+
const propAnimation = normalized.properties[key];
|
|
127
|
+
let animationValue = null;
|
|
128
|
+
return typeof propAnimation == "string" ? animationValue = animations[propAnimation] : propAnimation && typeof propAnimation == "object" && propAnimation.type ? animationValue = animations[propAnimation.type] : defaultAnimation && (animationValue = defaultAnimation), animationValue ? `${key} ${animationValue}${delayStr}` : null;
|
|
129
|
+
}).filter(Boolean).join(", "), process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("CSS animation", {
|
|
129
130
|
props,
|
|
130
131
|
animations,
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
normalized,
|
|
133
|
+
defaultAnimation,
|
|
133
134
|
style,
|
|
134
135
|
isEntering,
|
|
135
136
|
isExiting
|
|
136
|
-
}),
|
|
137
|
+
}), {
|
|
137
138
|
style,
|
|
138
139
|
className: isEntering ? "t_unmounted" : ""
|
|
139
|
-
}
|
|
140
|
+
};
|
|
140
141
|
}
|
|
141
142
|
};
|
|
142
143
|
}
|
|
@@ -25,7 +25,7 @@ __export(createAnimations_exports, {
|
|
|
25
25
|
createAnimations: () => createAnimations
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(createAnimations_exports);
|
|
28
|
-
var import_constants = require("@tamagui/constants"), import_use_presence = require("@tamagui/use-presence"), import_web = require("@tamagui/web"), import_react = __toESM(require("react"), 1);
|
|
28
|
+
var import_animation_helpers = require("@tamagui/animation-helpers"), import_constants = require("@tamagui/constants"), import_use_presence = require("@tamagui/use-presence"), import_web = require("@tamagui/web"), import_react = __toESM(require("react"), 1);
|
|
29
29
|
function extractDuration(animation) {
|
|
30
30
|
const msMatch = animation.match(/(\d+(?:\.\d+)?)\s*ms/);
|
|
31
31
|
if (msMatch)
|
|
@@ -76,11 +76,11 @@ function createAnimations(animations) {
|
|
|
76
76
|
return getStyle(val.getValue());
|
|
77
77
|
},
|
|
78
78
|
useAnimations: ({ props, presence, style, componentState, stateRef }) => {
|
|
79
|
-
const isEntering = !!componentState.unmounted, isExiting = presence?.[0] === !1, sendExitComplete = presence?.[1],
|
|
79
|
+
const isEntering = !!componentState.unmounted, isExiting = presence?.[0] === !1, sendExitComplete = presence?.[1], normalized = (0, import_animation_helpers.normalizeTransition)(props.transition), defaultAnimation = normalized.default ? animations[normalized.default] : null, animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized), keys = animatedProperties.length > 0 ? animatedProperties : props.animateOnly ?? ["all"];
|
|
80
80
|
if ((0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
81
81
|
const host = stateRef.current.host;
|
|
82
82
|
if (!sendExitComplete || !isExiting || !host) return;
|
|
83
|
-
const node = host, animationDuration =
|
|
83
|
+
const node = host, animationDuration = defaultAnimation ? extractDuration(defaultAnimation) : 200, delay = normalized.delay ?? 0, fallbackTimeout = animationDuration + delay, timeoutId = setTimeout(() => {
|
|
84
84
|
sendExitComplete?.();
|
|
85
85
|
}, fallbackTimeout), onFinishAnimation = () => {
|
|
86
86
|
clearTimeout(timeoutId), sendExitComplete?.();
|
|
@@ -88,23 +88,23 @@ function createAnimations(animations) {
|
|
|
88
88
|
return node.addEventListener("transitionend", onFinishAnimation), node.addEventListener("transitioncancel", onFinishAnimation), () => {
|
|
89
89
|
clearTimeout(timeoutId), node.removeEventListener("transitionend", onFinishAnimation), node.removeEventListener("transitioncancel", onFinishAnimation);
|
|
90
90
|
};
|
|
91
|
-
}, [sendExitComplete, isExiting]),
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
91
|
+
}, [sendExitComplete, isExiting]), !(0, import_animation_helpers.hasAnimation)(normalized))
|
|
92
|
+
return null;
|
|
93
|
+
Array.isArray(style.transform) && (style.transform = (0, import_web.transformsToString)(style.transform));
|
|
94
|
+
const delayStr = normalized.delay ? ` ${normalized.delay}ms` : "";
|
|
95
|
+
return style.transition = keys.map((key) => {
|
|
96
|
+
const propAnimation = normalized.properties[key];
|
|
97
|
+
let animationValue = null;
|
|
98
|
+
return typeof propAnimation == "string" ? animationValue = animations[propAnimation] : propAnimation && typeof propAnimation == "object" && propAnimation.type ? animationValue = animations[propAnimation.type] : defaultAnimation && (animationValue = defaultAnimation), animationValue ? `${key} ${animationValue}${delayStr}` : null;
|
|
99
|
+
}).filter(Boolean).join(", "), process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("CSS animation", {
|
|
100
100
|
props,
|
|
101
101
|
animations,
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
normalized,
|
|
103
|
+
defaultAnimation,
|
|
104
104
|
style,
|
|
105
105
|
isEntering,
|
|
106
106
|
isExiting
|
|
107
|
-
}),
|
|
107
|
+
}), { style, className: isEntering ? "t_unmounted" : "" };
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
110
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createAnimations.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,
|
|
5
|
-
"names": ["React", "onFinish"]
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAIO,uCACP,mBAA0C,+BAC1C,sBAA2C,kCAE3C,aAAmC,yBACnC,eAAgC;AAOhC,SAAS,gBAAgB,WAA2B;AAElD,QAAM,UAAU,UAAU,MAAM,sBAAsB;AACtD,MAAI;AACF,WAAO,OAAO,SAAS,QAAQ,CAAC,GAAG,EAAE;AAIvC,QAAM,SAAS,UAAU,MAAM,qBAAqB;AACpD,SAAI,SACK,KAAK,MAAM,OAAO,WAAW,OAAO,CAAC,CAAC,IAAI,GAAI,IAIhD;AACT;AAEO,SAAS,iBAAmC,YAAmC;AACpF,QAAM,oBAAoB,oBAAI,QAA4B;AAE1D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,oBAAoB;AAAA,IAEpB,kBAAkB,SAA4C;AAC5D,YAAM,CAAC,KAAK,MAAM,IAAI,aAAAA,QAAM,SAAS,OAAO,GACtC,CAAC,UAAU,WAAW,QAAI,uBAA+B;AAE/D,6DAA0B,MAAM;AAC9B,QAAI,aACF,WAAW,GACX,YAAY,MAAS;AAAA,MAEzB,GAAG,CAAC,QAAQ,CAAC,GAEN;AAAA,QACL,cAAc;AACZ,i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 __export(createAnimations_exports, {
|
|
|
36
36
|
createAnimations: () => createAnimations
|
|
37
37
|
});
|
|
38
38
|
module.exports = __toCommonJS(createAnimations_exports);
|
|
39
|
-
var
|
|
39
|
+
var import_animation_helpers = require("@tamagui/animation-helpers"),
|
|
40
|
+
import_constants = require("@tamagui/constants"),
|
|
40
41
|
import_use_presence = require("@tamagui/use-presence"),
|
|
41
42
|
import_web = require("@tamagui/web"),
|
|
42
43
|
import_react = __toESM(require("react"), 1);
|
|
44
|
+
function _type_of(obj) {
|
|
45
|
+
"@swc/helpers - typeof";
|
|
46
|
+
|
|
47
|
+
return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
48
|
+
}
|
|
43
49
|
function extractDuration(animation) {
|
|
44
50
|
var msMatch = animation.match(/(\d+(?:\.\d+)?)\s*ms/);
|
|
45
51
|
if (msMatch) return Number.parseInt(msMatch[1], 10);
|
|
@@ -102,17 +108,19 @@ function createAnimations(animations) {
|
|
|
102
108
|
isEntering = !!componentState.unmounted,
|
|
103
109
|
isExiting = presence?.[0] === !1,
|
|
104
110
|
sendExitComplete = presence?.[1],
|
|
105
|
-
|
|
106
|
-
|
|
111
|
+
normalized = (0, import_animation_helpers.normalizeTransition)(props.transition),
|
|
112
|
+
defaultAnimation = normalized.default ? animations[normalized.default] : null,
|
|
113
|
+
animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized),
|
|
107
114
|
_props_animateOnly,
|
|
108
|
-
keys = (_props_animateOnly = props.animateOnly) !== null && _props_animateOnly !== void 0 ? _props_animateOnly : ["all"];
|
|
115
|
+
keys = animatedProperties.length > 0 ? animatedProperties : (_props_animateOnly = props.animateOnly) !== null && _props_animateOnly !== void 0 ? _props_animateOnly : ["all"];
|
|
109
116
|
if ((0, import_constants.useIsomorphicLayoutEffect)(function () {
|
|
110
117
|
var host = stateRef.current.host;
|
|
111
118
|
if (!(!sendExitComplete || !isExiting || !host)) {
|
|
112
119
|
var node = host,
|
|
113
|
-
animationDuration =
|
|
114
|
-
|
|
115
|
-
|
|
120
|
+
animationDuration = defaultAnimation ? extractDuration(defaultAnimation) : 200,
|
|
121
|
+
_normalized_delay,
|
|
122
|
+
delay = (_normalized_delay = normalized.delay) !== null && _normalized_delay !== void 0 ? _normalized_delay : 0,
|
|
123
|
+
fallbackTimeout = animationDuration + delay,
|
|
116
124
|
timeoutId = setTimeout(function () {
|
|
117
125
|
sendExitComplete?.();
|
|
118
126
|
}, fallbackTimeout),
|
|
@@ -123,27 +131,25 @@ function createAnimations(animations) {
|
|
|
123
131
|
clearTimeout(timeoutId), node.removeEventListener("transitionend", onFinishAnimation), node.removeEventListener("transitioncancel", onFinishAnimation);
|
|
124
132
|
};
|
|
125
133
|
}
|
|
126
|
-
}, [sendExitComplete, isExiting]),
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
return process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("CSS animation", {
|
|
134
|
+
}, [sendExitComplete, isExiting]), !(0, import_animation_helpers.hasAnimation)(normalized)) return null;
|
|
135
|
+
Array.isArray(style.transform) && (style.transform = (0, import_web.transformsToString)(style.transform));
|
|
136
|
+
var delayStr = normalized.delay ? ` ${normalized.delay}ms` : "";
|
|
137
|
+
return style.transition = keys.map(function (key) {
|
|
138
|
+
var propAnimation = normalized.properties[key],
|
|
139
|
+
animationValue = null;
|
|
140
|
+
return typeof propAnimation == "string" ? animationValue = animations[propAnimation] : propAnimation && (typeof propAnimation > "u" ? "undefined" : _type_of(propAnimation)) === "object" && propAnimation.type ? animationValue = animations[propAnimation.type] : defaultAnimation && (animationValue = defaultAnimation), animationValue ? `${key} ${animationValue}${delayStr}` : null;
|
|
141
|
+
}).filter(Boolean).join(", "), process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("CSS animation", {
|
|
136
142
|
props,
|
|
137
143
|
animations,
|
|
138
|
-
|
|
139
|
-
|
|
144
|
+
normalized,
|
|
145
|
+
defaultAnimation,
|
|
140
146
|
style,
|
|
141
147
|
isEntering,
|
|
142
148
|
isExiting
|
|
143
|
-
}),
|
|
149
|
+
}), {
|
|
144
150
|
style,
|
|
145
151
|
className: isEntering ? "t_unmounted" : ""
|
|
146
|
-
}
|
|
152
|
+
};
|
|
147
153
|
}
|
|
148
154
|
};
|
|
149
155
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","createAnimations_exports","__export","createAnimations","module","exports","
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","createAnimations_exports","__export","createAnimations","module","exports","import_animation_helpers","require","import_constants","import_use_presence","import_web","import_react","__toESM","_type_of","obj","Symbol","constructor","extractDuration","animation","msMatch","match","Number","parseInt","sMatch","Math","round","parseFloat","animations","reactionListeners","WeakMap","usePresence","ResetPresence","supportsCSS","classNameAnimation","useAnimatedNumber","initial","val","setVal","default","useState","onFinish","setOnFinish","useIsomorphicLayoutEffect","getInstance","getValue","setValue","next","config","onFinish2","stop","useAnimatedNumberReaction","param","onValue","useEffect","instance","queue","get","Set","set","add","delete","useAnimatedNumberStyle","getStyle","useAnimations","props","presence","style","componentState","stateRef","isEntering","unmounted","isExiting","sendExitComplete","normalized","normalizeTransition","transition","defaultAnimation","animatedProperties","getAnimatedProperties","_props_animateOnly","keys","length","animateOnly","host","current","node","animationDuration","_normalized_delay","delay","fallbackTimeout","timeoutId","setTimeout","onFinishAnimation","clearTimeout","addEventListener","removeEventListener","hasAnimation","Array","isArray","transform","transformsToString","delayStr","map","key","propAnimation","properties","animationValue","type"],"sources":["../../src/createAnimations.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,wB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OAAAtB,KAAA,CAAAS,UAAA,GAAAK,IAAA,CAAAsB,GAAA,WAAAC,GAAA;QACF,IAAAC,aAAA,GAAA/B,UAAA,CAAAgC,UAAA,CAAAF,GAAA;UAAAG,cAAA;QACF,cAAAF,aAAA,eAAAE,cAAA,GAAA/E,UAAA,CAAA6E,aAAA,IAAAA,aAAA,YAAAA,aAAA,uBAAA3F,QAAA,CAAA2F,aAAA,mBAAAA,aAAA,CAAAG,IAAA,GAAAD,cAAA,GAAA/E,UAAA,CAAA6E,aAAA,CAAAG,IAAA,IAAA/B,gBAAA,KAAA8B,cAAA,GAAA9B,gBAAA,GAAA8B,cAAA,MAAAH,GAAA,IAAAG,cAAA,GAAAL,QAAA","ignoreList":[]}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeTransition,
|
|
3
|
+
getAnimatedProperties,
|
|
4
|
+
hasAnimation as hasNormalizedAnimation
|
|
5
|
+
} from "@tamagui/animation-helpers";
|
|
1
6
|
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
7
|
import { ResetPresence, usePresence } from "@tamagui/use-presence";
|
|
3
8
|
import { transformsToString } from "@tamagui/web";
|
|
@@ -52,11 +57,11 @@ function createAnimations(animations) {
|
|
|
52
57
|
return getStyle(val.getValue());
|
|
53
58
|
},
|
|
54
59
|
useAnimations: ({ props, presence, style, componentState, stateRef }) => {
|
|
55
|
-
const isEntering = !!componentState.unmounted, isExiting = presence?.[0] === !1, sendExitComplete = presence?.[1],
|
|
60
|
+
const isEntering = !!componentState.unmounted, isExiting = presence?.[0] === !1, sendExitComplete = presence?.[1], normalized = normalizeTransition(props.transition), defaultAnimation = normalized.default ? animations[normalized.default] : null, animatedProperties = getAnimatedProperties(normalized), keys = animatedProperties.length > 0 ? animatedProperties : props.animateOnly ?? ["all"];
|
|
56
61
|
if (useIsomorphicLayoutEffect(() => {
|
|
57
62
|
const host = stateRef.current.host;
|
|
58
63
|
if (!sendExitComplete || !isExiting || !host) return;
|
|
59
|
-
const node = host, animationDuration =
|
|
64
|
+
const node = host, animationDuration = defaultAnimation ? extractDuration(defaultAnimation) : 200, delay = normalized.delay ?? 0, fallbackTimeout = animationDuration + delay, timeoutId = setTimeout(() => {
|
|
60
65
|
sendExitComplete?.();
|
|
61
66
|
}, fallbackTimeout), onFinishAnimation = () => {
|
|
62
67
|
clearTimeout(timeoutId), sendExitComplete?.();
|
|
@@ -64,23 +69,23 @@ function createAnimations(animations) {
|
|
|
64
69
|
return node.addEventListener("transitionend", onFinishAnimation), node.addEventListener("transitioncancel", onFinishAnimation), () => {
|
|
65
70
|
clearTimeout(timeoutId), node.removeEventListener("transitionend", onFinishAnimation), node.removeEventListener("transitioncancel", onFinishAnimation);
|
|
66
71
|
};
|
|
67
|
-
}, [sendExitComplete, isExiting]),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
}, [sendExitComplete, isExiting]), !hasNormalizedAnimation(normalized))
|
|
73
|
+
return null;
|
|
74
|
+
Array.isArray(style.transform) && (style.transform = transformsToString(style.transform));
|
|
75
|
+
const delayStr = normalized.delay ? ` ${normalized.delay}ms` : "";
|
|
76
|
+
return style.transition = keys.map((key) => {
|
|
77
|
+
const propAnimation = normalized.properties[key];
|
|
78
|
+
let animationValue = null;
|
|
79
|
+
return typeof propAnimation == "string" ? animationValue = animations[propAnimation] : propAnimation && typeof propAnimation == "object" && propAnimation.type ? animationValue = animations[propAnimation.type] : defaultAnimation && (animationValue = defaultAnimation), animationValue ? `${key} ${animationValue}${delayStr}` : null;
|
|
80
|
+
}).filter(Boolean).join(", "), process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("CSS animation", {
|
|
76
81
|
props,
|
|
77
82
|
animations,
|
|
78
|
-
|
|
79
|
-
|
|
83
|
+
normalized,
|
|
84
|
+
defaultAnimation,
|
|
80
85
|
style,
|
|
81
86
|
isEntering,
|
|
82
87
|
isExiting
|
|
83
|
-
}),
|
|
88
|
+
}), { style, className: isEntering ? "t_unmounted" : "" };
|
|
84
89
|
}
|
|
85
90
|
};
|
|
86
91
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createAnimations.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,eAAe,mBAAmB;AAE3C,SAAS,0BAA0B;AACnC,OAAO,SAAS,gBAAgB;AAOhC,SAAS,gBAAgB,WAA2B;AAElD,QAAM,UAAU,UAAU,MAAM,sBAAsB;AACtD,MAAI;AACF,WAAO,OAAO,SAAS,QAAQ,CAAC,GAAG,EAAE;AAIvC,QAAM,SAAS,UAAU,MAAM,qBAAqB;AACpD,SAAI,SACK,KAAK,MAAM,OAAO,WAAW,OAAO,CAAC,CAAC,IAAI,GAAI,IAIhD;AACT;AAEO,SAAS,iBAAmC,YAAmC;AACpF,QAAM,oBAAoB,oBAAI,QAA4B;AAE1D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,oBAAoB;AAAA,IAEpB,kBAAkB,SAA4C;AAC5D,YAAM,CAAC,KAAK,MAAM,IAAI,MAAM,SAAS,OAAO,GACtC,CAAC,UAAU,WAAW,IAAI,SAA+B;AAE/D,uCAA0B,MAAM;AAC9B,QAAI,aACF,WAAW,GACX,YAAY,MAAS;AAAA,MAEzB,GAAG,CAAC,QAAQ,CAAC,GAEN;AAAA,QACL,cAAc;AACZ,iBAAO;AAAA,QACT;AAAA,QACA,WAAW;AACT,iBAAO;AAAA,QACT;AAAA,QACA,SAAS,MAAM,QAAQA,WAAU;AAC/B,iBAAO,IAAI,GACX,YAAYA,SAAQ;AAAA,QACtB;AAAA,QACA,OAAO;AAAA,QAAC;AAAA,MACV;AAAA,IACF;AAAA,IAEA,0BAA0B,EAAE,MAAM,GAAG,SAAS;AAC5C,Y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aAAa,gBAAgB,GAAG;AAAA,IAC7D;AAAA,EACF;AACF;",
|
|
5
5
|
"names": ["onFinish"]
|
|
6
6
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeTransition, getAnimatedProperties, hasAnimation as hasNormalizedAnimation } from "@tamagui/animation-helpers";
|
|
1
2
|
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
3
|
import { ResetPresence, usePresence } from "@tamagui/use-presence";
|
|
3
4
|
import { transformsToString } from "@tamagui/web";
|
|
@@ -62,15 +63,16 @@ function createAnimations(animations) {
|
|
|
62
63
|
const isEntering = !!componentState.unmounted,
|
|
63
64
|
isExiting = presence?.[0] === !1,
|
|
64
65
|
sendExitComplete = presence?.[1],
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
normalized = normalizeTransition(props.transition),
|
|
67
|
+
defaultAnimation = normalized.default ? animations[normalized.default] : null,
|
|
68
|
+
animatedProperties = getAnimatedProperties(normalized),
|
|
69
|
+
keys = animatedProperties.length > 0 ? animatedProperties : props.animateOnly ?? ["all"];
|
|
68
70
|
if (useIsomorphicLayoutEffect(() => {
|
|
69
71
|
const host = stateRef.current.host;
|
|
70
72
|
if (!sendExitComplete || !isExiting || !host) return;
|
|
71
73
|
const node = host,
|
|
72
|
-
animationDuration =
|
|
73
|
-
delay =
|
|
74
|
+
animationDuration = defaultAnimation ? extractDuration(defaultAnimation) : 200,
|
|
75
|
+
delay = normalized.delay ?? 0,
|
|
74
76
|
fallbackTimeout = animationDuration + delay,
|
|
75
77
|
timeoutId = setTimeout(() => {
|
|
76
78
|
sendExitComplete?.();
|
|
@@ -81,26 +83,25 @@ function createAnimations(animations) {
|
|
|
81
83
|
return node.addEventListener("transitionend", onFinishAnimation), node.addEventListener("transitioncancel", onFinishAnimation), () => {
|
|
82
84
|
clearTimeout(timeoutId), node.removeEventListener("transitionend", onFinishAnimation), node.removeEventListener("transitioncancel", onFinishAnimation);
|
|
83
85
|
};
|
|
84
|
-
}, [sendExitComplete, isExiting]),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
return process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("CSS animation", {
|
|
86
|
+
}, [sendExitComplete, isExiting]), !hasNormalizedAnimation(normalized)) return null;
|
|
87
|
+
Array.isArray(style.transform) && (style.transform = transformsToString(style.transform));
|
|
88
|
+
const delayStr = normalized.delay ? ` ${normalized.delay}ms` : "";
|
|
89
|
+
return style.transition = keys.map(key => {
|
|
90
|
+
const propAnimation = normalized.properties[key];
|
|
91
|
+
let animationValue = null;
|
|
92
|
+
return typeof propAnimation == "string" ? animationValue = animations[propAnimation] : propAnimation && typeof propAnimation == "object" && propAnimation.type ? animationValue = animations[propAnimation.type] : defaultAnimation && (animationValue = defaultAnimation), animationValue ? `${key} ${animationValue}${delayStr}` : null;
|
|
93
|
+
}).filter(Boolean).join(", "), process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("CSS animation", {
|
|
93
94
|
props,
|
|
94
95
|
animations,
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
normalized,
|
|
97
|
+
defaultAnimation,
|
|
97
98
|
style,
|
|
98
99
|
isEntering,
|
|
99
100
|
isExiting
|
|
100
|
-
}),
|
|
101
|
+
}), {
|
|
101
102
|
style,
|
|
102
103
|
className: isEntering ? "t_unmounted" : ""
|
|
103
|
-
}
|
|
104
|
+
};
|
|
104
105
|
}
|
|
105
106
|
};
|
|
106
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useIsomorphicLayoutEffect","ResetPresence","usePresence","transformsToString","React","useState","extractDuration","animation","msMatch","match","Number","parseInt","sMatch","Math","round","parseFloat","createAnimations","animations","reactionListeners","WeakMap","supportsCSS","classNameAnimation","useAnimatedNumber","initial","val","setVal","onFinish","setOnFinish","getInstance","getValue","setValue","next","config","onFinish2","stop","useAnimatedNumberReaction","value","onValue","useEffect","instance","queue","get","Set","set","add","delete","useAnimatedNumberStyle","getStyle","useAnimations","props","presence","style","componentState","stateRef","isEntering","unmounted","isExiting","sendExitComplete","
|
|
1
|
+
{"version":3,"names":["normalizeTransition","getAnimatedProperties","hasAnimation","hasNormalizedAnimation","useIsomorphicLayoutEffect","ResetPresence","usePresence","transformsToString","React","useState","extractDuration","animation","msMatch","match","Number","parseInt","sMatch","Math","round","parseFloat","createAnimations","animations","reactionListeners","WeakMap","supportsCSS","classNameAnimation","useAnimatedNumber","initial","val","setVal","onFinish","setOnFinish","getInstance","getValue","setValue","next","config","onFinish2","stop","useAnimatedNumberReaction","value","onValue","useEffect","instance","queue","get","Set","set","add","delete","useAnimatedNumberStyle","getStyle","useAnimations","props","presence","style","componentState","stateRef","isEntering","unmounted","isExiting","sendExitComplete","normalized","transition","defaultAnimation","default","animatedProperties","keys","length","animateOnly","host","current","node","animationDuration","delay","fallbackTimeout","timeoutId","setTimeout","onFinishAnimation","clearTimeout","addEventListener","removeEventListener","Array","isArray","transform","delayStr","map","key","propAnimation","properties","animationValue","type","filter","Boolean","join","process","env","NODE_ENV","debug","console","info","className"],"sources":["../../src/createAnimations.tsx"],"sourcesContent":[null],"mappings":"AAAA,SACEA,mBAAA,EACAC,qBAAA,EACAC,YAAA,IAAgBC,sBAAA,QACX;AACP,SAASC,yBAAA,QAAiC;AAC1C,SAASC,aAAA,EAAeC,WAAA,QAAmB;AAE3C,SAASC,kBAAA,QAA0B;AACnC,OAAOC,KAAA,IAASC,QAAA,QAAgB;AAOhC,SAASC,gBAAgBC,SAAA,EAA2B;EAElD,MAAMC,OAAA,GAAUD,SAAA,CAAUE,KAAA,CAAM,sBAAsB;EACtD,IAAID,OAAA,EACF,OAAOE,MAAA,CAAOC,QAAA,CAASH,OAAA,CAAQ,CAAC,GAAG,EAAE;EAIvC,MAAMI,MAAA,GAASL,SAAA,CAAUE,KAAA,CAAM,qBAAqB;EACpD,OAAIG,MAAA,GACKC,IAA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,aAC/DC,OAAA,CAAQC,IAAA,CAAK,iBAAiB;QAC5B/C,KAAA;QACAhC,UAAA;QACAyC,UAAA;QACAE,gBAAA;QACAT,KAAA;QACAG,UAAA;QACAE;MACF,CAAC,GAGI;QAAEL,KAAA;QAAO8C,SAAA,EAAW3C,UAAA,GAAa,gBAAgB;MAAG;IAC7D;EACF;AACF","ignoreList":[]}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { normalizeTransition, getAnimatedProperties, hasAnimation as hasNormalizedAnimation } from "@tamagui/animation-helpers";
|
|
1
2
|
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
2
3
|
import { ResetPresence, usePresence } from "@tamagui/use-presence";
|
|
3
4
|
import { transformsToString } from "@tamagui/web";
|
|
4
5
|
import React, { useState } from "react";
|
|
6
|
+
function _type_of(obj) {
|
|
7
|
+
"@swc/helpers - typeof";
|
|
8
|
+
|
|
9
|
+
return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
10
|
+
}
|
|
5
11
|
function extractDuration(animation) {
|
|
6
12
|
var msMatch = animation.match(/(\d+(?:\.\d+)?)\s*ms/);
|
|
7
13
|
if (msMatch) return Number.parseInt(msMatch[1], 10);
|
|
@@ -64,17 +70,19 @@ function createAnimations(animations) {
|
|
|
64
70
|
isEntering = !!componentState.unmounted,
|
|
65
71
|
isExiting = presence?.[0] === !1,
|
|
66
72
|
sendExitComplete = presence?.[1],
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
normalized = normalizeTransition(props.transition),
|
|
74
|
+
defaultAnimation = normalized.default ? animations[normalized.default] : null,
|
|
75
|
+
animatedProperties = getAnimatedProperties(normalized),
|
|
69
76
|
_props_animateOnly,
|
|
70
|
-
keys = (_props_animateOnly = props.animateOnly) !== null && _props_animateOnly !== void 0 ? _props_animateOnly : ["all"];
|
|
77
|
+
keys = animatedProperties.length > 0 ? animatedProperties : (_props_animateOnly = props.animateOnly) !== null && _props_animateOnly !== void 0 ? _props_animateOnly : ["all"];
|
|
71
78
|
if (useIsomorphicLayoutEffect(function () {
|
|
72
79
|
var host = stateRef.current.host;
|
|
73
80
|
if (!(!sendExitComplete || !isExiting || !host)) {
|
|
74
81
|
var node = host,
|
|
75
|
-
animationDuration =
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
animationDuration = defaultAnimation ? extractDuration(defaultAnimation) : 200,
|
|
83
|
+
_normalized_delay,
|
|
84
|
+
delay = (_normalized_delay = normalized.delay) !== null && _normalized_delay !== void 0 ? _normalized_delay : 0,
|
|
85
|
+
fallbackTimeout = animationDuration + delay,
|
|
78
86
|
timeoutId = setTimeout(function () {
|
|
79
87
|
sendExitComplete?.();
|
|
80
88
|
}, fallbackTimeout),
|
|
@@ -85,27 +93,25 @@ function createAnimations(animations) {
|
|
|
85
93
|
clearTimeout(timeoutId), node.removeEventListener("transitionend", onFinishAnimation), node.removeEventListener("transitioncancel", onFinishAnimation);
|
|
86
94
|
};
|
|
87
95
|
}
|
|
88
|
-
}, [sendExitComplete, isExiting]),
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
return process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("CSS animation", {
|
|
96
|
+
}, [sendExitComplete, isExiting]), !hasNormalizedAnimation(normalized)) return null;
|
|
97
|
+
Array.isArray(style.transform) && (style.transform = transformsToString(style.transform));
|
|
98
|
+
var delayStr = normalized.delay ? ` ${normalized.delay}ms` : "";
|
|
99
|
+
return style.transition = keys.map(function (key) {
|
|
100
|
+
var propAnimation = normalized.properties[key],
|
|
101
|
+
animationValue = null;
|
|
102
|
+
return typeof propAnimation == "string" ? animationValue = animations[propAnimation] : propAnimation && (typeof propAnimation > "u" ? "undefined" : _type_of(propAnimation)) === "object" && propAnimation.type ? animationValue = animations[propAnimation.type] : defaultAnimation && (animationValue = defaultAnimation), animationValue ? `${key} ${animationValue}${delayStr}` : null;
|
|
103
|
+
}).filter(Boolean).join(", "), process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("CSS animation", {
|
|
98
104
|
props,
|
|
99
105
|
animations,
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
normalized,
|
|
107
|
+
defaultAnimation,
|
|
102
108
|
style,
|
|
103
109
|
isEntering,
|
|
104
110
|
isExiting
|
|
105
|
-
}),
|
|
111
|
+
}), {
|
|
106
112
|
style,
|
|
107
113
|
className: isEntering ? "t_unmounted" : ""
|
|
108
|
-
}
|
|
114
|
+
};
|
|
109
115
|
}
|
|
110
116
|
};
|
|
111
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useIsomorphicLayoutEffect","ResetPresence","usePresence","transformsToString","React","useState","extractDuration","animation","msMatch","match","Number","parseInt","sMatch","Math","round","parseFloat","createAnimations","animations","reactionListeners","WeakMap","supportsCSS","classNameAnimation","useAnimatedNumber","initial","val","setVal","onFinish","setOnFinish","getInstance","getValue","setValue","next","config","onFinish2","stop","useAnimatedNumberReaction","param","onValue","value","useEffect","instance","queue","get","Set","set","add","delete","useAnimatedNumberStyle","getStyle","useAnimations","props","presence","style","componentState","stateRef","isEntering","unmounted","isExiting","sendExitComplete","
|
|
1
|
+
{"version":3,"names":["normalizeTransition","getAnimatedProperties","hasAnimation","hasNormalizedAnimation","useIsomorphicLayoutEffect","ResetPresence","usePresence","transformsToString","React","useState","_type_of","obj","Symbol","constructor","extractDuration","animation","msMatch","match","Number","parseInt","sMatch","Math","round","parseFloat","createAnimations","animations","reactionListeners","WeakMap","supportsCSS","classNameAnimation","useAnimatedNumber","initial","val","setVal","onFinish","setOnFinish","getInstance","getValue","setValue","next","config","onFinish2","stop","useAnimatedNumberReaction","param","onValue","value","useEffect","instance","queue","get","Set","set","add","delete","useAnimatedNumberStyle","getStyle","useAnimations","props","presence","style","componentState","stateRef","isEntering","unmounted","isExiting","sendExitComplete","normalized","transition","defaultAnimation","default","animatedProperties","_props_animateOnly","keys","length","animateOnly","host","current","node","animationDuration","_normalized_delay","delay","fallbackTimeout","timeoutId","setTimeout","onFinishAnimation","clearTimeout","addEventListener","removeEventListener","Array","isArray","transform","delayStr","map","key","propAnimation","properties","animationValue","type","filter","Boolean","join","process","env","NODE_ENV","debug","console","info"],"sources":["../../src/createAnimations.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAAAA,mBAAA,EAAAC,qBAAA,EAAAC,YAAA,IAAAC,sBAAA;AAAA,SACEC,yBAAA;AAAA,SACAC,aAAA,EAAAC,WAAA;AAAA,SACAC,kBAAgB;AAAA,OACXC,KAAA,IAAAC,QAAA;AACP,SAASC,SAAAC,GAAA;EACT,uBAAwB;;EAExB,OAASA,GAAA,WAAAC,MAAA,MAA0B,IAAAD,GAAA,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AACnC;AAOA,SAASG,gBAAgBC,SAAA,EAA2B;EAElD,IAAAC,OAAM,GAAAD,SAAU,CAAAE,KAAU,uBAAM;EAChC,IAAID,OAAA,EACF,OAAOE,MAAA,CAAOC,QAAA,CAASH,OAAA,CAAQ,CAAC,GAAG,EAAE;EAIvC,IAAAI,MAAM,GAAAL,SAAS,CAAAE,KAAU,sBAAM;EAC/B,OAAIG,MAAA,GACKC,IAAA,CAAKC,KAAA,CAAMJ,MAAA,CAAOK,UAAA,CAAWH,MAAA,CAAO,CAAC,CAAC,IAAI,GAAI,IAIhD;AACT;AAEO,SAASI,iBAAmCC,UAAA,EAAmC;EACpF,IAAAC,iBAAM,kBAAoB,IAAAC,OAAI;EAE9B,OAAO;IACLF,UAAA;IACAnB,WAAA;IACAD,aAAA;IACAuB,WAAA,EAAa;IACbC,kBAAA,EAAoB;IAEpBC,kBAAkBC,OAAA,EAA4C;MAC5D,KAAAC,GAAO,EAAAC,MAAK,IAAMzB,KAAI,CAAAC,QAAM,CAAAsB,OAAS;QAAO,CAAAG,QACrC,EAAAC,WAAU,IAAW1B,QAAI;MAEhC,OAAAL,yBA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AK,IAAA,CAAAoB,GAAA,WAAAC,GAAA;QACA,IAAAC,aAAA,GAAA5B,UAAA,CAAA6B,UAAA,CAAAF,GAAA;UAAAG,cAAA;QACA,cAAAF,aAAA,eAAAE,cAAA,GAAAxE,UAAA,CAAAsE,aAAA,IAAAA,aAAA,YAAAA,aAAA,uBAAArF,QAAA,CAAAqF,aAAA,mBAAAA,aAAA,CAAAG,IAAA,GAAAD,cAAA,GAAAxE,UAAA,CAAAsE,aAAA,CAAAG,IAAA,IAAA7B,gBAAA,KAAA4B,cAAA,GAAA5B,gBAAA,GAAA4B,cAAA,MAAAH,GAAA,IAAAG,cAAA,GAAAL,QAAA;MAAA,EACA,CAAAO,MAAA,CAAAC,OAAA,EAAAC,IAAA,QAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,sBAAA9C,KAAA,CAAA+C,KAAA,kBAAAC,OAAA,CAAAC,IAAA;QACDjD,KAGM;QACXjC,UAAA;QACF0C,UAAA;QACFE,gBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/animations-css",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-1768530912818",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,13 +29,14 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tamagui/
|
|
33
|
-
"@tamagui/
|
|
34
|
-
"@tamagui/
|
|
35
|
-
"@tamagui/
|
|
32
|
+
"@tamagui/animation-helpers": "2.0.0-1768530912818",
|
|
33
|
+
"@tamagui/constants": "2.0.0-1768530912818",
|
|
34
|
+
"@tamagui/cubic-bezier-animator": "2.0.0-1768530912818",
|
|
35
|
+
"@tamagui/use-presence": "2.0.0-1768530912818",
|
|
36
|
+
"@tamagui/web": "2.0.0-1768530912818"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@tamagui/build": "2.0.0-
|
|
39
|
+
"@tamagui/build": "2.0.0-1768530912818",
|
|
39
40
|
"react": "*",
|
|
40
41
|
"react-dom": "*"
|
|
41
42
|
},
|
package/src/createAnimations.tsx
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
normalizeTransition,
|
|
3
|
+
getAnimatedProperties,
|
|
4
|
+
hasAnimation as hasNormalizedAnimation,
|
|
5
|
+
} from '@tamagui/animation-helpers'
|
|
1
6
|
import { useIsomorphicLayoutEffect } from '@tamagui/constants'
|
|
2
7
|
import { ResetPresence, usePresence } from '@tamagui/use-presence'
|
|
3
8
|
import type { AnimationDriver, UniversalAnimatedNumber } from '@tamagui/web'
|
|
@@ -86,12 +91,17 @@ export function createAnimations<A extends Object>(animations: A): AnimationDriv
|
|
|
86
91
|
const isEntering = !!componentState.unmounted
|
|
87
92
|
const isExiting = presence?.[0] === false
|
|
88
93
|
const sendExitComplete = presence?.[1]
|
|
89
|
-
//
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
// Normalize the transition prop to a consistent format
|
|
95
|
+
const normalized = normalizeTransition(props.transition)
|
|
96
|
+
const defaultAnimation = normalized.default ? animations[normalized.default] : null
|
|
97
|
+
const animatedProperties = getAnimatedProperties(normalized)
|
|
98
|
+
|
|
99
|
+
// Determine which properties to animate
|
|
100
|
+
// If object format with properties specified, use those; otherwise use animateOnly or 'all'
|
|
101
|
+
const keys =
|
|
102
|
+
animatedProperties.length > 0
|
|
103
|
+
? animatedProperties
|
|
104
|
+
: (props.animateOnly ?? ['all'])
|
|
95
105
|
|
|
96
106
|
useIsomorphicLayoutEffect(() => {
|
|
97
107
|
const host = stateRef.current.host
|
|
@@ -108,9 +118,10 @@ export function createAnimations<A extends Object>(animations: A): AnimationDriv
|
|
|
108
118
|
*/
|
|
109
119
|
|
|
110
120
|
// Use timeout as primary, transition events as backup for reliable exit handling
|
|
111
|
-
const animationDuration =
|
|
112
|
-
|
|
113
|
-
|
|
121
|
+
const animationDuration = defaultAnimation
|
|
122
|
+
? extractDuration(defaultAnimation)
|
|
123
|
+
: 200
|
|
124
|
+
const delay = normalized.delay ?? 0
|
|
114
125
|
const fallbackTimeout = animationDuration + delay
|
|
115
126
|
|
|
116
127
|
const timeoutId = setTimeout(() => {
|
|
@@ -133,40 +144,54 @@ export function createAnimations<A extends Object>(animations: A): AnimationDriv
|
|
|
133
144
|
}
|
|
134
145
|
}, [sendExitComplete, isExiting])
|
|
135
146
|
|
|
136
|
-
if
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
147
|
+
// Check if we have any animation to apply
|
|
148
|
+
if (!hasNormalizedAnimation(normalized)) {
|
|
149
|
+
return null
|
|
150
|
+
}
|
|
140
151
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// for non layout transform properties either use animate function or find a workaround to do it with css
|
|
144
|
-
const delay =
|
|
145
|
-
typeof animationConfig?.delay === 'number' ? ` ${animationConfig.delay}ms` : ''
|
|
146
|
-
style.transition = keys
|
|
147
|
-
.map((key) => {
|
|
148
|
-
const override = animations[animationConfig?.[key]] ?? animation
|
|
149
|
-
return `${key} ${override}${delay}`
|
|
150
|
-
})
|
|
151
|
-
.join(', ')
|
|
152
|
+
if (Array.isArray(style.transform)) {
|
|
153
|
+
style.transform = transformsToString(style.transform)
|
|
152
154
|
}
|
|
153
155
|
|
|
156
|
+
// Build CSS transition string
|
|
157
|
+
// TODO: we disabled the transform transition, because it will create issue for inverse function and animate function
|
|
158
|
+
// for non layout transform properties either use animate function or find a workaround to do it with css
|
|
159
|
+
const delayStr = normalized.delay ? ` ${normalized.delay}ms` : ''
|
|
160
|
+
style.transition = keys
|
|
161
|
+
.map((key) => {
|
|
162
|
+
// Check for property-specific animation, fall back to default
|
|
163
|
+
const propAnimation = normalized.properties[key]
|
|
164
|
+
let animationValue: string | null = null
|
|
165
|
+
|
|
166
|
+
if (typeof propAnimation === 'string') {
|
|
167
|
+
animationValue = animations[propAnimation]
|
|
168
|
+
} else if (
|
|
169
|
+
propAnimation &&
|
|
170
|
+
typeof propAnimation === 'object' &&
|
|
171
|
+
propAnimation.type
|
|
172
|
+
) {
|
|
173
|
+
animationValue = animations[propAnimation.type]
|
|
174
|
+
} else if (defaultAnimation) {
|
|
175
|
+
animationValue = defaultAnimation
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return animationValue ? `${key} ${animationValue}${delayStr}` : null
|
|
179
|
+
})
|
|
180
|
+
.filter(Boolean)
|
|
181
|
+
.join(', ')
|
|
182
|
+
|
|
154
183
|
if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {
|
|
155
184
|
console.info('CSS animation', {
|
|
156
185
|
props,
|
|
157
186
|
animations,
|
|
158
|
-
|
|
159
|
-
|
|
187
|
+
normalized,
|
|
188
|
+
defaultAnimation,
|
|
160
189
|
style,
|
|
161
190
|
isEntering,
|
|
162
191
|
isExiting,
|
|
163
192
|
})
|
|
164
193
|
}
|
|
165
194
|
|
|
166
|
-
if (!animation) {
|
|
167
|
-
return null
|
|
168
|
-
}
|
|
169
|
-
|
|
170
195
|
return { style, className: isEntering ? 't_unmounted' : '' }
|
|
171
196
|
},
|
|
172
197
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "
|
|
2
|
+
"mappings": "AAOA,cAAc,uBAAgD;AA0B9D,OAAO,iBAAS,iBAAiB,UAAU,QAAQ,YAAY,IAAI,gBAAgB",
|
|
3
3
|
"names": [],
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/createAnimations.tsx"
|
|
6
6
|
],
|
|
7
7
|
"sourcesContent": [
|
|
8
|
-
"import { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { ResetPresence, usePresence } from '@tamagui/use-presence'\nimport type { AnimationDriver, UniversalAnimatedNumber } from '@tamagui/web'\nimport { transformsToString } from '@tamagui/web'\nimport React, { useState } from 'react' // import { animate } from '@tamagui/cubic-bezier-animator'\n\n/**\n * Helper function to extract duration from CSS animation string\n * Examples: \"ease-in 200ms\" -> 200, \"cubic-bezier(0.215, 0.610, 0.355, 1.000) 400ms\" -> 400\n * \"ease-in 0.5s\" -> 500, \"slow 2s\" -> 2000\n */\nfunction extractDuration(animation: string): number {\n // Try to match milliseconds first\n const msMatch = animation.match(/(\\d+(?:\\.\\d+)?)\\s*ms/)\n if (msMatch) {\n return Number.parseInt(msMatch[1], 10)\n }\n\n // Try to match seconds and convert to milliseconds\n const sMatch = animation.match(/(\\d+(?:\\.\\d+)?)\\s*s/)\n if (sMatch) {\n return Math.round(Number.parseFloat(sMatch[1]) * 1000)\n }\n\n // Default to 300ms if no duration found\n return 300\n}\n\nexport function createAnimations<A extends Object>(animations: A): AnimationDriver<A> {\n const reactionListeners = new WeakMap<any, Set<Function>>()\n\n return {\n animations,\n usePresence,\n ResetPresence,\n supportsCSS: true,\n classNameAnimation: true,\n\n useAnimatedNumber(initial): UniversalAnimatedNumber<Function> {\n const [val, setVal] = React.useState(initial)\n const [onFinish, setOnFinish] = useState<Function | undefined>()\n\n useIsomorphicLayoutEffect(() => {\n if (onFinish) {\n onFinish?.()\n setOnFinish(undefined)\n }\n }, [onFinish])\n\n return {\n getInstance() {\n return setVal\n },\n getValue() {\n return val\n },\n setValue(next, config, onFinish) {\n setVal(next)\n setOnFinish(onFinish)\n },\n stop() {},\n }\n },\n\n useAnimatedNumberReaction({ value }, onValue) {\n React.useEffect(() => {\n const instance = value.getInstance()\n let queue = reactionListeners.get(instance)\n if (!queue) {\n const next = new Set<Function>()\n reactionListeners.set(instance, next)\n queue = next!\n }\n queue.add(onValue)\n return () => {\n queue?.delete(onValue)\n }\n }, [])\n },\n\n useAnimatedNumberStyle(val, getStyle) {\n return getStyle(val.getValue())\n },\n\n useAnimations: ({ props, presence, style, componentState, stateRef }) => {\n const isEntering = !!componentState.unmounted\n const isExiting = presence?.[0] === false\n const sendExitComplete = presence?.[1]\n //
|
|
8
|
+
"import {\n normalizeTransition,\n getAnimatedProperties,\n hasAnimation as hasNormalizedAnimation,\n} from '@tamagui/animation-helpers'\nimport { useIsomorphicLayoutEffect } from '@tamagui/constants'\nimport { ResetPresence, usePresence } from '@tamagui/use-presence'\nimport type { AnimationDriver, UniversalAnimatedNumber } from '@tamagui/web'\nimport { transformsToString } from '@tamagui/web'\nimport React, { useState } from 'react' // import { animate } from '@tamagui/cubic-bezier-animator'\n\n/**\n * Helper function to extract duration from CSS animation string\n * Examples: \"ease-in 200ms\" -> 200, \"cubic-bezier(0.215, 0.610, 0.355, 1.000) 400ms\" -> 400\n * \"ease-in 0.5s\" -> 500, \"slow 2s\" -> 2000\n */\nfunction extractDuration(animation: string): number {\n // Try to match milliseconds first\n const msMatch = animation.match(/(\\d+(?:\\.\\d+)?)\\s*ms/)\n if (msMatch) {\n return Number.parseInt(msMatch[1], 10)\n }\n\n // Try to match seconds and convert to milliseconds\n const sMatch = animation.match(/(\\d+(?:\\.\\d+)?)\\s*s/)\n if (sMatch) {\n return Math.round(Number.parseFloat(sMatch[1]) * 1000)\n }\n\n // Default to 300ms if no duration found\n return 300\n}\n\nexport function createAnimations<A extends Object>(animations: A): AnimationDriver<A> {\n const reactionListeners = new WeakMap<any, Set<Function>>()\n\n return {\n animations,\n usePresence,\n ResetPresence,\n supportsCSS: true,\n classNameAnimation: true,\n\n useAnimatedNumber(initial): UniversalAnimatedNumber<Function> {\n const [val, setVal] = React.useState(initial)\n const [onFinish, setOnFinish] = useState<Function | undefined>()\n\n useIsomorphicLayoutEffect(() => {\n if (onFinish) {\n onFinish?.()\n setOnFinish(undefined)\n }\n }, [onFinish])\n\n return {\n getInstance() {\n return setVal\n },\n getValue() {\n return val\n },\n setValue(next, config, onFinish) {\n setVal(next)\n setOnFinish(onFinish)\n },\n stop() {},\n }\n },\n\n useAnimatedNumberReaction({ value }, onValue) {\n React.useEffect(() => {\n const instance = value.getInstance()\n let queue = reactionListeners.get(instance)\n if (!queue) {\n const next = new Set<Function>()\n reactionListeners.set(instance, next)\n queue = next!\n }\n queue.add(onValue)\n return () => {\n queue?.delete(onValue)\n }\n }, [])\n },\n\n useAnimatedNumberStyle(val, getStyle) {\n return getStyle(val.getValue())\n },\n\n useAnimations: ({ props, presence, style, componentState, stateRef }) => {\n const isEntering = !!componentState.unmounted\n const isExiting = presence?.[0] === false\n const sendExitComplete = presence?.[1]\n // Normalize the transition prop to a consistent format\n const normalized = normalizeTransition(props.transition)\n const defaultAnimation = normalized.default ? animations[normalized.default] : null\n const animatedProperties = getAnimatedProperties(normalized)\n\n // Determine which properties to animate\n // If object format with properties specified, use those; otherwise use animateOnly or 'all'\n const keys =\n animatedProperties.length > 0\n ? animatedProperties\n : (props.animateOnly ?? ['all'])\n\n useIsomorphicLayoutEffect(() => {\n const host = stateRef.current.host\n if (!sendExitComplete || !isExiting || !host) return\n const node = host as HTMLElement\n\n /**\n * Exit animation handling for Dialog/Modal components\n *\n * The Challenge: When users close dialogs (via Escape key or clicking outside),\n * the element can disappear from the DOM before CSS transitions finish, which causes:\n * 1. Dialogs to stick around on screen\n * 2. Event handlers to stop working\n */\n\n // Use timeout as primary, transition events as backup for reliable exit handling\n const animationDuration = defaultAnimation\n ? extractDuration(defaultAnimation)\n : 200\n const delay = normalized.delay ?? 0\n const fallbackTimeout = animationDuration + delay\n\n const timeoutId = setTimeout(() => {\n sendExitComplete?.()\n }, fallbackTimeout)\n\n // Listen for transition completion events as backup\n const onFinishAnimation = () => {\n clearTimeout(timeoutId)\n sendExitComplete?.()\n }\n\n node.addEventListener('transitionend', onFinishAnimation)\n node.addEventListener('transitioncancel', onFinishAnimation)\n\n return () => {\n clearTimeout(timeoutId)\n node.removeEventListener('transitionend', onFinishAnimation)\n node.removeEventListener('transitioncancel', onFinishAnimation)\n }\n }, [sendExitComplete, isExiting])\n\n // Check if we have any animation to apply\n if (!hasNormalizedAnimation(normalized)) {\n return null\n }\n\n if (Array.isArray(style.transform)) {\n style.transform = transformsToString(style.transform)\n }\n\n // Build CSS transition string\n // TODO: we disabled the transform transition, because it will create issue for inverse function and animate function\n // for non layout transform properties either use animate function or find a workaround to do it with css\n const delayStr = normalized.delay ? ` ${normalized.delay}ms` : ''\n style.transition = keys\n .map((key) => {\n // Check for property-specific animation, fall back to default\n const propAnimation = normalized.properties[key]\n let animationValue: string | null = null\n\n if (typeof propAnimation === 'string') {\n animationValue = animations[propAnimation]\n } else if (\n propAnimation &&\n typeof propAnimation === 'object' &&\n propAnimation.type\n ) {\n animationValue = animations[propAnimation.type]\n } else if (defaultAnimation) {\n animationValue = defaultAnimation\n }\n\n return animationValue ? `${key} ${animationValue}${delayStr}` : null\n })\n .filter(Boolean)\n .join(', ')\n\n if (process.env.NODE_ENV === 'development' && props['debug'] === 'verbose') {\n console.info('CSS animation', {\n props,\n animations,\n normalized,\n defaultAnimation,\n style,\n isEntering,\n isExiting,\n })\n }\n\n return { style, className: isEntering ? 't_unmounted' : '' }\n },\n }\n}\n\n// layout animations\n// useIsomorphicLayoutEffect(() => {\n// if (!host || !props.layout) {\n// return\n// }\n// // @ts-ignore\n// const boundingBox = host?.getBoundingClientRect()\n// if (isChanged(initialPositionRef.current, boundingBox)) {\n// const transform = invert(\n// host,\n// boundingBox,\n// initialPositionRef.current\n// )\n\n// animate({\n// from: transform,\n// to: { x: 0, y: 0, scaleX: 1, scaleY: 1 },\n// duration: 1000,\n// onUpdate: ({ x, y, scaleX, scaleY }) => {\n// // @ts-ignore\n// host.style.transform = `translate(${x}px, ${y}px) scaleX(${scaleX}) scaleY(${scaleY})`\n// // TODO: handle childRef inverse scale\n// // childRef.current.style.transform = `scaleX(${1 / scaleX}) scaleY(${\n// // 1 / scaleY\n// // })`\n// },\n// // TODO: extract ease-in from string and convert/map it to a cubicBezier array\n// cubicBezier: [0, 1.38, 1, -0.41],\n// })\n// }\n// initialPositionRef.current = boundingBox\n// })\n\n// style.transition = `${keys} ${animation}${\n// props.layout ? ',width 0s, height 0s, margin 0s, padding 0s, transform' : ''\n// }`\n\n// const isChanged = (initialBox: any, finalBox: any) => {\n// // we just mounted, so we don't have complete data yet\n// if (!initialBox || !finalBox) return false\n\n// // deep compare the two boxes\n// return JSON.stringify(initialBox) !== JSON.stringify(finalBox)\n// }\n\n// const invert = (el, from, to) => {\n// const { x: fromX, y: fromY, width: fromWidth, height: fromHeight } = from\n// const { x, y, width, height } = to\n\n// const transform = {\n// x: x - fromX - (fromWidth - width) / 2,\n// y: y - fromY - (fromHeight - height) / 2,\n// scaleX: width / fromWidth,\n// scaleY: height / fromHeight,\n// }\n\n// el.style.transform = `\n"
|
|
9
9
|
],
|
|
10
10
|
"version": 3
|
|
11
11
|
}
|