@tamagui/animations-css 2.0.0-1769080004701 → 2.0.0-1769154615570
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 +10 -4
- package/dist/cjs/createAnimations.js +6 -2
- package/dist/cjs/createAnimations.js.map +1 -1
- package/dist/cjs/createAnimations.native.js +11 -4
- package/dist/cjs/createAnimations.native.js.map +1 -1
- package/dist/esm/createAnimations.js +8 -3
- package/dist/esm/createAnimations.js.map +1 -1
- package/dist/esm/createAnimations.mjs +11 -5
- package/dist/esm/createAnimations.mjs.map +1 -1
- package/dist/esm/createAnimations.native.js +12 -5
- package/dist/esm/createAnimations.native.js.map +1 -1
- package/package.json +7 -7
- package/src/createAnimations.tsx +29 -4
- package/types/createAnimations.d.ts.map +2 -2
|
@@ -101,13 +101,19 @@ function createAnimations(animations) {
|
|
|
101
101
|
const isEntering = !!componentState.unmounted,
|
|
102
102
|
isExiting = presence?.[0] === !1,
|
|
103
103
|
sendExitComplete = presence?.[1],
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
wasEnteringRef = import_react.default.useRef(isEntering),
|
|
105
|
+
justFinishedEntering = wasEnteringRef.current && !isEntering;
|
|
106
|
+
import_react.default.useEffect(() => {
|
|
107
|
+
wasEnteringRef.current = isEntering;
|
|
108
|
+
});
|
|
109
|
+
const normalized = (0, import_animation_helpers.normalizeTransition)(props.transition),
|
|
110
|
+
effectiveAnimationKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default"),
|
|
111
|
+
defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null,
|
|
106
112
|
animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized),
|
|
107
|
-
hasDefault = normalized.default !== null,
|
|
113
|
+
hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null,
|
|
108
114
|
hasPerPropertyConfigs = animatedProperties.length > 0;
|
|
109
115
|
let keys;
|
|
110
|
-
if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = [
|
|
116
|
+
if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = ["all", ...animatedProperties] : keys = ["all"], (0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
111
117
|
const host = stateRef.current.host;
|
|
112
118
|
if (!sendExitComplete || !isExiting || !host) return;
|
|
113
119
|
const node = host,
|
|
@@ -78,9 +78,13 @@ function createAnimations(animations) {
|
|
|
78
78
|
return getStyle(val.getValue());
|
|
79
79
|
},
|
|
80
80
|
useAnimations: ({ props, presence, style, componentState, stateRef }) => {
|
|
81
|
-
const isEntering = !!componentState.unmounted, isExiting = presence?.[0] === !1, sendExitComplete = presence?.[1],
|
|
81
|
+
const isEntering = !!componentState.unmounted, isExiting = presence?.[0] === !1, sendExitComplete = presence?.[1], wasEnteringRef = import_react.default.useRef(isEntering), justFinishedEntering = wasEnteringRef.current && !isEntering;
|
|
82
|
+
import_react.default.useEffect(() => {
|
|
83
|
+
wasEnteringRef.current = isEntering;
|
|
84
|
+
});
|
|
85
|
+
const normalized = (0, import_animation_helpers.normalizeTransition)(props.transition), effectiveAnimationKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default"), defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null, animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized), hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null, hasPerPropertyConfigs = animatedProperties.length > 0;
|
|
82
86
|
let keys;
|
|
83
|
-
if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = [
|
|
87
|
+
if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = ["all", ...animatedProperties] : keys = ["all"], (0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
84
88
|
const host = stateRef.current.host;
|
|
85
89
|
if (!sendExitComplete || !isExiting || !host) return;
|
|
86
90
|
const node = host, animationDuration = defaultAnimation ? extractDuration(defaultAnimation) : 200, delay = normalized.delay ?? 0, fallbackTimeout = animationDuration + delay, timeoutId = setTimeout(() => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createAnimations.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAKO,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,G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AAO,iBAAkB,WAC3B,iBAAiB,WAAW,aAAa,IAEzC,iBACA,OAAO,iBAAkB,YACzB,cAAc,OAEd,iBAAiB,WAAW,cAAc,IAAI,IACrC,qBACT,iBAAiB,mBAGZ,iBAAiB,GAAG,GAAG,IAAI,cAAc,GAAG,QAAQ,KAAK;AAAA,MAClE,CAAC,EACA,OAAO,OAAO,EACd,KAAK,IAAI,GAER,QAAQ,IAAI,aAAa,iBAAiB,MAAM,UAAa,aAC/D,QAAQ,KAAK,iBAAiB;AAAA,QAC5B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC,GAGI,EAAE,OAAO,WAAW,aAAa,gBAAgB,GAAG;AAAA,IAC7D;AAAA,EACF;AACF;",
|
|
5
5
|
"names": ["React", "onFinish", "hasNormalizedAnimation"]
|
|
6
6
|
}
|
|
@@ -112,13 +112,20 @@ function createAnimations(animations) {
|
|
|
112
112
|
isEntering = !!componentState.unmounted,
|
|
113
113
|
isExiting = presence?.[0] === !1,
|
|
114
114
|
sendExitComplete = presence?.[1],
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
wasEnteringRef = import_react.default.useRef(isEntering),
|
|
116
|
+
justFinishedEntering = wasEnteringRef.current && !isEntering;
|
|
117
|
+
import_react.default.useEffect(function () {
|
|
118
|
+
wasEnteringRef.current = isEntering;
|
|
119
|
+
});
|
|
120
|
+
var normalized = (0, import_animation_helpers.normalizeTransition)(props.transition),
|
|
121
|
+
animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default",
|
|
122
|
+
effectiveAnimationKey = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState),
|
|
123
|
+
defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null,
|
|
117
124
|
animatedProperties = (0, import_animation_helpers.getAnimatedProperties)(normalized),
|
|
118
|
-
hasDefault = normalized.default !== null,
|
|
125
|
+
hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null,
|
|
119
126
|
hasPerPropertyConfigs = animatedProperties.length > 0,
|
|
120
127
|
keys;
|
|
121
|
-
if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = [
|
|
128
|
+
if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = ["all", ...animatedProperties] : keys = ["all"], (0, import_constants.useIsomorphicLayoutEffect)(function () {
|
|
122
129
|
var host = stateRef.current.host;
|
|
123
130
|
if (!(!sendExitComplete || !isExiting || !host)) {
|
|
124
131
|
var node = host,
|
|
@@ -1 +1 @@
|
|
|
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","listeners","get","forEach","listener","stop","useAnimatedNumberReaction","param","onValue","useEffect","instance","queue","Set","set","add","delete","useAnimatedNumberStyle","getStyle","useAnimations","props","presence","style","componentState","stateRef","isEntering","unmounted","isExiting","sendExitComplete","normalized","normalizeTransition","transition","defaultAnimation","animatedProperties","getAnimatedProperties","hasDefault","hasPerPropertyConfigs","length","keys","animateOnly","host","
|
|
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","listeners","get","forEach","listener","stop","useAnimatedNumberReaction","param","onValue","useEffect","instance","queue","Set","set","add","delete","useAnimatedNumberStyle","getStyle","useAnimations","props","presence","style","componentState","stateRef","isEntering","unmounted","isExiting","sendExitComplete","wasEnteringRef","useRef","justFinishedEntering","current","normalized","normalizeTransition","transition","animationState","effectiveAnimationKey","getEffectiveAnimation","defaultAnimation","animatedProperties","getAnimatedProperties","hasDefault","enter","exit","hasPerPropertyConfigs","length","keys","animateOnly","host","node","animationDuration","_normalized_delay","delay","fallbackTimeout","timeoutId","setTimeout","onFinishAnimation","clearTimeout","addEventListener","removeEventListener","hasAnimation","Array","isArray","transform","transformsToString"],"sources":["../../src/createAnimations.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,wBAAA;AAAAC,QAAA,CAAAD,wBAAA;EAAAE,gBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAT,YAAA,CAAAK,wBAKO;AAYP,IAAAK,wBAAyB,GAAAC,OAA2B;EAAAC,gBAAA,GAAAD,OAAA;EAAAE,mBAAA,GAAAF,OAAA;EAAAG,UAAA,GAAAH,OAAA;EAAAI,YAAA,GAAAC,OAAA,CAAAL,OAAA;AAElD,SAAMM,SAAUC,GAAA;EAChB,uBAAI;;EACF,OAAAA,GAAO,WAAOC,MAAS,MAAQ,IAAID,GAAE,CAAAE,WAAA,KAAAD,MAAA,qBAAAD,GAAA;AAIvC;AACA,SAAIG,eACUA,CAAAC,SAAM,EAAO;EAK7B,IAAAC,OAAA,GAAAD,SAAA,CAAAE,KAAA;EAEO,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KAAA,CAAAC,OAAA,CAAAzC,KAAA,CAAA0C,SAAA,MAAA1C,KAAA,CAAA0C,SAAA,OAAArG,UAAA,CAAAsG,kBAAA,EAAA3C,KAAA,CAAA0C,SAAA","ignoreList":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
normalizeTransition,
|
|
3
3
|
getAnimatedProperties,
|
|
4
|
-
hasAnimation as hasNormalizedAnimation
|
|
4
|
+
hasAnimation as hasNormalizedAnimation,
|
|
5
|
+
getEffectiveAnimation
|
|
5
6
|
} from "@tamagui/animation-helpers";
|
|
6
7
|
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
7
8
|
import { ResetPresence, usePresence } from "@tamagui/use-presence";
|
|
@@ -59,9 +60,13 @@ function createAnimations(animations) {
|
|
|
59
60
|
return getStyle(val.getValue());
|
|
60
61
|
},
|
|
61
62
|
useAnimations: ({ props, presence, style, componentState, stateRef }) => {
|
|
62
|
-
const isEntering = !!componentState.unmounted, isExiting = presence?.[0] === !1, sendExitComplete = presence?.[1],
|
|
63
|
+
const isEntering = !!componentState.unmounted, isExiting = presence?.[0] === !1, sendExitComplete = presence?.[1], wasEnteringRef = React.useRef(isEntering), justFinishedEntering = wasEnteringRef.current && !isEntering;
|
|
64
|
+
React.useEffect(() => {
|
|
65
|
+
wasEnteringRef.current = isEntering;
|
|
66
|
+
});
|
|
67
|
+
const normalized = normalizeTransition(props.transition), effectiveAnimationKey = getEffectiveAnimation(normalized, isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default"), defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null, animatedProperties = getAnimatedProperties(normalized), hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null, hasPerPropertyConfigs = animatedProperties.length > 0;
|
|
63
68
|
let keys;
|
|
64
|
-
if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = [
|
|
69
|
+
if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = ["all", ...animatedProperties] : keys = ["all"], useIsomorphicLayoutEffect(() => {
|
|
65
70
|
const host = stateRef.current.host;
|
|
66
71
|
if (!sendExitComplete || !isExiting || !host) return;
|
|
67
72
|
const node = host, animationDuration = defaultAnimation ? extractDuration(defaultAnimation) : 200, delay = normalized.delay ?? 0, fallbackTimeout = animationDuration + delay, timeoutId = setTimeout(() => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createAnimations.tsx"],
|
|
4
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,
|
|
4
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,OACK;AACP,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;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AkB,WAC3B,iBAAiB,WAAW,aAAa,IAEzC,iBACA,OAAO,iBAAkB,YACzB,cAAc,OAEd,iBAAiB,WAAW,cAAc,IAAI,IACrC,qBACT,iBAAiB,mBAGZ,iBAAiB,GAAG,GAAG,IAAI,cAAc,GAAG,QAAQ,KAAK;AAAA,MAClE,CAAC,EACA,OAAO,OAAO,EACd,KAAK,IAAI,GAER,QAAQ,IAAI,aAAa,iBAAiB,MAAM,UAAa,aAC/D,QAAQ,KAAK,iBAAiB;AAAA,QAC5B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC,GAGI,EAAE,OAAO,WAAW,aAAa,gBAAgB,GAAG;AAAA,IAC7D;AAAA,EACF;AACF;",
|
|
5
5
|
"names": ["onFinish"]
|
|
6
6
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeTransition, getAnimatedProperties, hasAnimation as hasNormalizedAnimation } from "@tamagui/animation-helpers";
|
|
1
|
+
import { normalizeTransition, getAnimatedProperties, hasAnimation as hasNormalizedAnimation, getEffectiveAnimation } from "@tamagui/animation-helpers";
|
|
2
2
|
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
3
3
|
import { ResetPresence, usePresence } from "@tamagui/use-presence";
|
|
4
4
|
import { transformsToString } from "@tamagui/web";
|
|
@@ -65,13 +65,19 @@ function createAnimations(animations) {
|
|
|
65
65
|
const isEntering = !!componentState.unmounted,
|
|
66
66
|
isExiting = presence?.[0] === !1,
|
|
67
67
|
sendExitComplete = presence?.[1],
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
wasEnteringRef = React.useRef(isEntering),
|
|
69
|
+
justFinishedEntering = wasEnteringRef.current && !isEntering;
|
|
70
|
+
React.useEffect(() => {
|
|
71
|
+
wasEnteringRef.current = isEntering;
|
|
72
|
+
});
|
|
73
|
+
const normalized = normalizeTransition(props.transition),
|
|
74
|
+
effectiveAnimationKey = getEffectiveAnimation(normalized, isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default"),
|
|
75
|
+
defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null,
|
|
70
76
|
animatedProperties = getAnimatedProperties(normalized),
|
|
71
|
-
hasDefault = normalized.default !== null,
|
|
77
|
+
hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null,
|
|
72
78
|
hasPerPropertyConfigs = animatedProperties.length > 0;
|
|
73
79
|
let keys;
|
|
74
|
-
if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = [
|
|
80
|
+
if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = ["all", ...animatedProperties] : keys = ["all"], useIsomorphicLayoutEffect(() => {
|
|
75
81
|
const host = stateRef.current.host;
|
|
76
82
|
if (!sendExitComplete || !isExiting || !host) return;
|
|
77
83
|
const node = host,
|
|
@@ -1 +1 @@
|
|
|
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","listeners","get","forEach","listener","stop","useAnimatedNumberReaction","value","onValue","useEffect","instance","queue","Set","set","add","delete","useAnimatedNumberStyle","getStyle","useAnimations","props","presence","style","componentState","stateRef","isEntering","unmounted","isExiting","sendExitComplete","normalized","transition","
|
|
1
|
+
{"version":3,"names":["normalizeTransition","getAnimatedProperties","hasAnimation","hasNormalizedAnimation","getEffectiveAnimation","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","listeners","get","forEach","listener","stop","useAnimatedNumberReaction","value","onValue","useEffect","instance","queue","Set","set","add","delete","useAnimatedNumberStyle","getStyle","useAnimations","props","presence","style","componentState","stateRef","isEntering","unmounted","isExiting","sendExitComplete","wasEnteringRef","useRef","justFinishedEntering","current","normalized","transition","effectiveAnimationKey","defaultAnimation","animatedProperties","hasDefault","default","enter","exit","hasPerPropertyConfigs","length","keys","animateOnly","host","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,EAChBC,qBAAA,QACK;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,IAAA,CAAKC,KAAA,CAAMJ,MAAA,CAAOK,UAAA,CAAWH,MAAA,CAAO,CAAC,CAAC,IAAI,GAAI,IAIhD;AACT;AAEO,SAASI,iBAAmCC,UAAA,EAAmC;EACpF,MAAMC,iBA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K,OAAO;MAC/D,OAAA3B,KAAA,CAAMY,UAAA,GAAaU,IAAA,CAChBiB,GAAA,CAAKC,GAAA,IAAQ;QAEZ,MAAMC,aAAA,GAAgB9B,UAAA,CAAW+B,UAAA,CAAWF,GAAG;QAC/C,IAAIG,cAAA,GAAgC;QAEpC,OAAI,OAAOF,aAAA,IAAkB,WAC3BE,cAAA,GAAiBhF,UAAA,CAAW8E,aAAa,IAEzCA,aAAA,IACA,OAAOA,aAAA,IAAkB,YACzBA,aAAA,CAAcG,IAAA,GAEdD,cAAA,GAAiBhF,UAAA,CAAW8E,aAAA,CAAcG,IAAI,IACrC9B,gBAAA,KACT6B,cAAA,GAAiB7B,gBAAA,GAGZ6B,cAAA,GAAiB,GAAGH,GAAG,IAAIG,cAAc,GAAGL,QAAQ,KAAK;MAClE,CAAC,EACAO,MAAA,CAAOC,OAAO,EACdC,IAAA,CAAK,IAAI,GAERC,OAAA,CAAQC,GAAA,CAAIC,QAAA,KAAa,iBAAiBpD,KAAA,CAAMqD,KAAA,KAAa,aAC/DC,OAAA,CAAQC,IAAA,CAAK,iBAAiB;QAC5BvD,KAAA;QACAnC,UAAA;QACAgD,UAAA;QACAG,gBAAA;QACAd,KAAA;QACAG,UAAA;QACAE;MACF,CAAC,GAGI;QAAEL,KAAA;QAAOsD,SAAA,EAAWnD,UAAA,GAAa,gBAAgB;MAAG;IAC7D;EACF;AACF","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeTransition, getAnimatedProperties, hasAnimation as hasNormalizedAnimation } from "@tamagui/animation-helpers";
|
|
1
|
+
import { normalizeTransition, getAnimatedProperties, hasAnimation as hasNormalizedAnimation, getEffectiveAnimation } from "@tamagui/animation-helpers";
|
|
2
2
|
import { useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
3
3
|
import { ResetPresence, usePresence } from "@tamagui/use-presence";
|
|
4
4
|
import { transformsToString } from "@tamagui/web";
|
|
@@ -74,13 +74,20 @@ function createAnimations(animations) {
|
|
|
74
74
|
isEntering = !!componentState.unmounted,
|
|
75
75
|
isExiting = presence?.[0] === !1,
|
|
76
76
|
sendExitComplete = presence?.[1],
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
wasEnteringRef = React.useRef(isEntering),
|
|
78
|
+
justFinishedEntering = wasEnteringRef.current && !isEntering;
|
|
79
|
+
React.useEffect(function () {
|
|
80
|
+
wasEnteringRef.current = isEntering;
|
|
81
|
+
});
|
|
82
|
+
var normalized = normalizeTransition(props.transition),
|
|
83
|
+
animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default",
|
|
84
|
+
effectiveAnimationKey = getEffectiveAnimation(normalized, animationState),
|
|
85
|
+
defaultAnimation = effectiveAnimationKey ? animations[effectiveAnimationKey] : null,
|
|
79
86
|
animatedProperties = getAnimatedProperties(normalized),
|
|
80
|
-
hasDefault = normalized.default !== null,
|
|
87
|
+
hasDefault = normalized.default !== null || normalized.enter !== null || normalized.exit !== null,
|
|
81
88
|
hasPerPropertyConfigs = animatedProperties.length > 0,
|
|
82
89
|
keys;
|
|
83
|
-
if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = [
|
|
90
|
+
if (props.animateOnly ? keys = props.animateOnly : hasPerPropertyConfigs && !hasDefault ? keys = animatedProperties : hasPerPropertyConfigs && hasDefault ? keys = ["all", ...animatedProperties] : keys = ["all"], useIsomorphicLayoutEffect(function () {
|
|
84
91
|
var host = stateRef.current.host;
|
|
85
92
|
if (!(!sendExitComplete || !isExiting || !host)) {
|
|
86
93
|
var node = host,
|
|
@@ -1 +1 @@
|
|
|
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","listeners","get","forEach","listener","stop","useAnimatedNumberReaction","param","onValue","value","useEffect","instance","queue","Set","set","add","delete","useAnimatedNumberStyle","getStyle","useAnimations","props","presence","style","componentState","stateRef","isEntering","unmounted","isExiting","sendExitComplete","normalized","transition","
|
|
1
|
+
{"version":3,"names":["normalizeTransition","getAnimatedProperties","hasAnimation","hasNormalizedAnimation","getEffectiveAnimation","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","listeners","get","forEach","listener","stop","useAnimatedNumberReaction","param","onValue","value","useEffect","instance","queue","Set","set","add","delete","useAnimatedNumberStyle","getStyle","useAnimations","props","presence","style","componentState","stateRef","isEntering","unmounted","isExiting","sendExitComplete","wasEnteringRef","useRef","justFinishedEntering","current","normalized","transition","animationState","effectiveAnimationKey","defaultAnimation","animatedProperties","hasDefault","default","enter","exit","hasPerPropertyConfigs","length","keys","animateOnly","host","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,EAAAC,qBAAA;AAAA,SACEC,yBAAA;AAAA,SACAC,aAAA,EAAAC,WAAA;AAAA,SACAC,kBAAgB;AAAA,OAChBC,KAAA,IAAAC,QAAA;AAAA,SACKC,SAAA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AAC,OAAA,CAAAtC,KAAA,CAAAuC,SAAA,MAAAvC,KAAA,CAAAuC,SAAA,GAAA/F,kBAAA,CAAAwD,KAAA,CAAAuC,SAAA;MAAA,IACAC,QAAA,GAAA7B,UAAA,CAAAkB,KAAA,OAAAlB,UAAA,CAAAkB,KAAA;MAAA,OACA7B,KAAA,CAAAY,UAAA,GAAAW,IAAA,CAAAkB,GAAA,WAAAC,GAAA;QACD,IAGMC,aAAO,GAAAhC,UAAW,CAAAiC,UAAa,CAAAF,GAAA;UAAAG,cAAmB;QAC7D,cAAAF,aAAA,eAAAE,cAAA,GAAAnF,UAAA,CAAAiF,aAAA,IAAAA,aAAA,YAAAA,aAAA,uBAAAhG,QAAA,CAAAgG,aAAA,mBAAAA,aAAA,CAAAG,IAAA,GAAAD,cAAA,GAAAnF,UAAA,CAAAiF,aAAA,CAAAG,IAAA,IAAA/B,gBAAA,KAAA8B,cAAA,GAAA9B,gBAAA,GAAA8B,cAAA,MAAAH,GAAA,IAAAG,cAAA,GAAAL,QAAA;MACF,GAAAO,MAAA,CAAAC,OAAA,EAAAC,IAAA,QAAAC,OAAA,CAAAC,GAAA,CAAAC,QAAA,sBAAAtD,KAAA,CAAAuD,KAAA,kBAAAC,OAAA,CAAAC,IAAA;QACFzD,KAAA","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-1769154615570",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tamagui/animation-helpers": "2.0.0-
|
|
33
|
-
"@tamagui/constants": "2.0.0-
|
|
34
|
-
"@tamagui/cubic-bezier-animator": "2.0.0-
|
|
35
|
-
"@tamagui/use-presence": "2.0.0-
|
|
36
|
-
"@tamagui/web": "2.0.0-
|
|
32
|
+
"@tamagui/animation-helpers": "2.0.0-1769154615570",
|
|
33
|
+
"@tamagui/constants": "2.0.0-1769154615570",
|
|
34
|
+
"@tamagui/cubic-bezier-animator": "2.0.0-1769154615570",
|
|
35
|
+
"@tamagui/use-presence": "2.0.0-1769154615570",
|
|
36
|
+
"@tamagui/web": "2.0.0-1769154615570"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@tamagui/build": "2.0.0-
|
|
39
|
+
"@tamagui/build": "2.0.0-1769154615570",
|
|
40
40
|
"react": "*",
|
|
41
41
|
"react-dom": "*"
|
|
42
42
|
},
|
package/src/createAnimations.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
normalizeTransition,
|
|
3
3
|
getAnimatedProperties,
|
|
4
4
|
hasAnimation as hasNormalizedAnimation,
|
|
5
|
+
getEffectiveAnimation,
|
|
5
6
|
} from '@tamagui/animation-helpers'
|
|
6
7
|
import { useIsomorphicLayoutEffect } from '@tamagui/constants'
|
|
7
8
|
import { ResetPresence, usePresence } from '@tamagui/use-presence'
|
|
@@ -96,16 +97,39 @@ export function createAnimations<A extends Object>(animations: A): AnimationDriv
|
|
|
96
97
|
const isEntering = !!componentState.unmounted
|
|
97
98
|
const isExiting = presence?.[0] === false
|
|
98
99
|
const sendExitComplete = presence?.[1]
|
|
100
|
+
|
|
101
|
+
// Track if we just finished entering (transition from entering to not entering)
|
|
102
|
+
// This is needed because the CSS transition happens on the render AFTER t_unmounted is removed
|
|
103
|
+
const wasEnteringRef = React.useRef(isEntering)
|
|
104
|
+
const justFinishedEntering = wasEnteringRef.current && !isEntering
|
|
105
|
+
React.useEffect(() => {
|
|
106
|
+
wasEnteringRef.current = isEntering
|
|
107
|
+
})
|
|
108
|
+
|
|
99
109
|
// Normalize the transition prop to a consistent format
|
|
100
110
|
const normalized = normalizeTransition(props.transition)
|
|
101
|
-
|
|
111
|
+
|
|
112
|
+
// Determine animation state and get effective animation
|
|
113
|
+
// Use 'enter' if we're entering OR if we just finished entering (transition is happening)
|
|
114
|
+
const animationState = isExiting
|
|
115
|
+
? 'exit'
|
|
116
|
+
: isEntering || justFinishedEntering
|
|
117
|
+
? 'enter'
|
|
118
|
+
: 'default'
|
|
119
|
+
const effectiveAnimationKey = getEffectiveAnimation(normalized, animationState)
|
|
120
|
+
const defaultAnimation = effectiveAnimationKey
|
|
121
|
+
? animations[effectiveAnimationKey]
|
|
122
|
+
: null
|
|
102
123
|
const animatedProperties = getAnimatedProperties(normalized)
|
|
103
124
|
|
|
104
125
|
// Determine which properties to animate
|
|
105
126
|
// - animateOnly prop is an exclusive filter (only animate those properties)
|
|
106
127
|
// - per-property configs WITHOUT a default = only animate those specific properties
|
|
107
128
|
// - per-property configs WITH a default = per-property overrides + default for rest
|
|
108
|
-
const hasDefault =
|
|
129
|
+
const hasDefault =
|
|
130
|
+
normalized.default !== null ||
|
|
131
|
+
normalized.enter !== null ||
|
|
132
|
+
normalized.exit !== null
|
|
109
133
|
const hasPerPropertyConfigs = animatedProperties.length > 0
|
|
110
134
|
|
|
111
135
|
let keys: string[]
|
|
@@ -116,8 +140,9 @@ export function createAnimations<A extends Object>(animations: A): AnimationDriv
|
|
|
116
140
|
// object format without default: { opacity: '200ms' } = only animate opacity
|
|
117
141
|
keys = animatedProperties
|
|
118
142
|
} else if (hasPerPropertyConfigs && hasDefault) {
|
|
119
|
-
// array format or object with default: per-property overrides
|
|
120
|
-
|
|
143
|
+
// array format or object with default: 'all' first, then per-property overrides
|
|
144
|
+
// CSS transition specificity: later declarations override earlier ones for the same property
|
|
145
|
+
keys = ['all', ...animatedProperties]
|
|
121
146
|
} else {
|
|
122
147
|
// simple string format: 'quick' = animate all
|
|
123
148
|
keys = ['all']
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"mappings": "
|
|
2
|
+
"mappings": "AAQA,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 {\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 // call reaction listeners with the new value\n const listeners = reactionListeners.get(setVal)\n if (listeners) {\n listeners.forEach((listener) => listener(next))\n }\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 // - animateOnly prop is an exclusive filter (only animate those properties)\n // - per-property configs WITHOUT a default = only animate those specific properties\n // - per-property configs WITH a default = per-property overrides + default for rest\n const hasDefault = normalized.default !== null\n const hasPerPropertyConfigs = animatedProperties.length > 0\n\n let keys: string[]\n if (props.animateOnly) {\n // animateOnly is explicit filter\n keys = props.animateOnly\n } else if (hasPerPropertyConfigs && !hasDefault) {\n // object format without default: { opacity: '200ms' } = only animate opacity\n keys = animatedProperties\n } else if (hasPerPropertyConfigs && hasDefault) {\n // array format or object with default: per-property overrides + 'all' for rest\n keys = [...animatedProperties, 'all']\n } else {\n // simple string format: 'quick' = animate all\n keys = ['all']\n }\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"
|
|
8
|
+
"import {\n normalizeTransition,\n getAnimatedProperties,\n hasAnimation as hasNormalizedAnimation,\n getEffectiveAnimation,\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 // call reaction listeners with the new value\n const listeners = reactionListeners.get(setVal)\n if (listeners) {\n listeners.forEach((listener) => listener(next))\n }\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\n // Track if we just finished entering (transition from entering to not entering)\n // This is needed because the CSS transition happens on the render AFTER t_unmounted is removed\n const wasEnteringRef = React.useRef(isEntering)\n const justFinishedEntering = wasEnteringRef.current && !isEntering\n React.useEffect(() => {\n wasEnteringRef.current = isEntering\n })\n\n // Normalize the transition prop to a consistent format\n const normalized = normalizeTransition(props.transition)\n\n // Determine animation state and get effective animation\n // Use 'enter' if we're entering OR if we just finished entering (transition is happening)\n const animationState = isExiting\n ? 'exit'\n : isEntering || justFinishedEntering\n ? 'enter'\n : 'default'\n const effectiveAnimationKey = getEffectiveAnimation(normalized, animationState)\n const defaultAnimation = effectiveAnimationKey\n ? animations[effectiveAnimationKey]\n : null\n const animatedProperties = getAnimatedProperties(normalized)\n\n // Determine which properties to animate\n // - animateOnly prop is an exclusive filter (only animate those properties)\n // - per-property configs WITHOUT a default = only animate those specific properties\n // - per-property configs WITH a default = per-property overrides + default for rest\n const hasDefault =\n normalized.default !== null ||\n normalized.enter !== null ||\n normalized.exit !== null\n const hasPerPropertyConfigs = animatedProperties.length > 0\n\n let keys: string[]\n if (props.animateOnly) {\n // animateOnly is explicit filter\n keys = props.animateOnly\n } else if (hasPerPropertyConfigs && !hasDefault) {\n // object format without default: { opacity: '200ms' } = only animate opacity\n keys = animatedProperties\n } else if (hasPerPropertyConfigs && hasDefault) {\n // array format or object with default: 'all' first, then per-property overrides\n // CSS transition specificity: later declarations override earlier ones for the same property\n keys = ['all', ...animatedProperties]\n } else {\n // simple string format: 'quick' = animate all\n keys = ['all']\n }\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
|
}
|