@tamagui/animations-motion 1.129.6 → 1.129.7
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 +14 -13
- package/dist/cjs/createAnimations.js +21 -14
- package/dist/cjs/createAnimations.js.map +1 -1
- package/dist/cjs/createAnimations.native.js +15 -14
- package/dist/cjs/createAnimations.native.js.map +2 -2
- package/dist/esm/createAnimations.js +21 -14
- package/dist/esm/createAnimations.js.map +1 -1
- package/dist/esm/createAnimations.mjs +14 -13
- package/dist/esm/createAnimations.mjs.map +1 -1
- package/dist/esm/createAnimations.native.js +14 -13
- package/dist/esm/createAnimations.native.js.map +1 -1
- package/package.json +4 -4
- package/src/createAnimations.tsx +35 -19
- package/types/createAnimations.d.ts.map +1 -1
|
@@ -77,18 +77,24 @@ function createAnimations(animationsProp) {
|
|
|
77
77
|
doAnimate,
|
|
78
78
|
animationOptions
|
|
79
79
|
} = (0, import_react2.useMemo)(() => getMotionAnimatedProps(props, style, disableAnimation), [presenceContext, animationKey, styleKey]),
|
|
80
|
-
runAnimation = (
|
|
81
|
-
if (!
|
|
82
|
-
if ((0, import_core.fixStyles)(
|
|
83
|
-
lastAnimationStyle.current =
|
|
80
|
+
runAnimation = (nextStyle, animationOptions2) => {
|
|
81
|
+
if (!nextStyle || !(stateRef.current.host instanceof HTMLElement)) return;
|
|
82
|
+
if ((0, import_core.fixStyles)(nextStyle), (0, import_core.styleToCSS)(nextStyle), !lastAnimationStyle.current) {
|
|
83
|
+
lastAnimationStyle.current = nextStyle, controls.current = animate(scope.current, nextStyle, {
|
|
84
84
|
duration: 0,
|
|
85
85
|
type: "tween"
|
|
86
|
-
}), controls.current.complete();
|
|
86
|
+
}), controls.current.complete(), scope.animations = [];
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
89
|
const diff = {};
|
|
90
|
-
for (const key in
|
|
91
|
-
|
|
90
|
+
for (const key in nextStyle) nextStyle[key] !== lastAnimationStyle.current[key] && (diff[key] = nextStyle[key]);
|
|
91
|
+
process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-motion] animate (", JSON.stringify(diff, null, 2) + ")"), scope.animations = scope.animations.filter(x => {
|
|
92
|
+
try {
|
|
93
|
+
return x.state !== "finished" && x.state !== "idle";
|
|
94
|
+
} catch {
|
|
95
|
+
return !0;
|
|
96
|
+
}
|
|
97
|
+
}), controls.current = animate(scope.current, diff, animationOptions2), lastAnimationStyle.current = nextStyle;
|
|
92
98
|
};
|
|
93
99
|
return useStyleEmitter?.(nextStyle => {
|
|
94
100
|
const {
|
|
@@ -100,12 +106,7 @@ function createAnimations(animationsProp) {
|
|
|
100
106
|
lastAnimationStyle.current = null;
|
|
101
107
|
}, []), (0, import_react2.useLayoutEffect)(() => {
|
|
102
108
|
doAnimate && runAnimation(doAnimate, animationOptions);
|
|
103
|
-
}, [JSON.stringify(doAnimate), lastAnimationStyle]), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-motion](", JSON.stringify(
|
|
104
|
-
doAnimate,
|
|
105
|
-
dontAnimate,
|
|
106
|
-
animationOptions,
|
|
107
|
-
props
|
|
108
|
-
}), {
|
|
109
|
+
}, [JSON.stringify(doAnimate), lastAnimationStyle]), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-motion] render (", JSON.stringify(dontAnimate, null, 2) + ")"), {
|
|
109
110
|
style: dontAnimate,
|
|
110
111
|
ref: scope,
|
|
111
112
|
tag: "div"
|
|
@@ -50,20 +50,29 @@ function createAnimations(animationsProp) {
|
|
|
50
50
|
props,
|
|
51
51
|
style,
|
|
52
52
|
disableAnimation
|
|
53
|
-
), [presenceContext, animationKey, styleKey]), runAnimation = (
|
|
54
|
-
if (!
|
|
53
|
+
), [presenceContext, animationKey, styleKey]), runAnimation = (nextStyle, animationOptions2) => {
|
|
54
|
+
if (!nextStyle || !(stateRef.current.host instanceof HTMLElement))
|
|
55
55
|
return;
|
|
56
|
-
if ((0, import_core.fixStyles)(
|
|
57
|
-
lastAnimationStyle.current =
|
|
56
|
+
if ((0, import_core.fixStyles)(nextStyle), (0, import_core.styleToCSS)(nextStyle), !lastAnimationStyle.current) {
|
|
57
|
+
lastAnimationStyle.current = nextStyle, controls.current = animate(scope.current, nextStyle, {
|
|
58
58
|
duration: 0,
|
|
59
59
|
type: "tween"
|
|
60
|
-
}), controls.current.complete();
|
|
60
|
+
}), controls.current.complete(), scope.animations = [];
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
const diff = {};
|
|
64
|
-
for (const key in
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
for (const key in nextStyle)
|
|
65
|
+
nextStyle[key] !== lastAnimationStyle.current[key] && (diff[key] = nextStyle[key]);
|
|
66
|
+
process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info(
|
|
67
|
+
"[animations-motion] animate (",
|
|
68
|
+
JSON.stringify(diff, null, 2) + ")"
|
|
69
|
+
), scope.animations = scope.animations.filter((x) => {
|
|
70
|
+
try {
|
|
71
|
+
return x.state !== "finished" && x.state !== "idle";
|
|
72
|
+
} catch {
|
|
73
|
+
return !0;
|
|
74
|
+
}
|
|
75
|
+
}), controls.current = animate(scope.current, diff, animationOptions2), lastAnimationStyle.current = nextStyle;
|
|
67
76
|
};
|
|
68
77
|
return useStyleEmitter?.((nextStyle) => {
|
|
69
78
|
const { doAnimate: doAnimate2, animationOptions: animationOptions2 } = getMotionAnimatedProps(
|
|
@@ -76,12 +85,10 @@ function createAnimations(animationsProp) {
|
|
|
76
85
|
lastAnimationStyle.current = null;
|
|
77
86
|
}, []), (0, import_react2.useLayoutEffect)(() => {
|
|
78
87
|
doAnimate && runAnimation(doAnimate, animationOptions);
|
|
79
|
-
}, [JSON.stringify(doAnimate), lastAnimationStyle]), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info(
|
|
80
|
-
|
|
81
|
-
dontAnimate,
|
|
82
|
-
|
|
83
|
-
props
|
|
84
|
-
}), {
|
|
88
|
+
}, [JSON.stringify(doAnimate), lastAnimationStyle]), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info(
|
|
89
|
+
"[animations-motion] render (",
|
|
90
|
+
JSON.stringify(dontAnimate, null, 2) + ")"
|
|
91
|
+
), {
|
|
85
92
|
style: dontAnimate,
|
|
86
93
|
ref: scope,
|
|
87
94
|
tag: "div"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createAnimations.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAaO,0BACP,sBAA4D,kCAC5D,eAQO,yBACPA,gBAA+E,
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAaO,0BACP,sBAA4D,kCAC5D,eAQO,yBACPA,gBAA+E,2BAoapE;AAxZX,MAAM,sBAAsB,oBAAI,QAA6C;AAEtE,SAAS,iBACd,gBACoB;AAIpB,QAAM,aAAgB,CAAC;AACvB,aAAW,OAAO;AAChB,eAAW,GAAG,IAAI;AAAA,MAChB,MAAM;AAAA,MACN,GAAG,eAAe,GAAG;AAAA,IACvB;AAGF,SAAO;AAAA;AAAA,IAEL,MAAM;AAAA,IACN,MAAM;AAAA,IACN,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB,gBAAgB;AAAA,IAChB,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IAEA,eAAe,CAAC,mBAAmB;AACjC,YAAM,EAAE,OAAO,OAAO,gBAAgB,UAAU,gBAAgB,IAAI,gBAE9D,eAAe,MAAM,QAAQ,MAAM,SAAS,IAC9C,MAAM,UAAU,CAAC,IACjB,MAAM,WAGJ,mBADc,eAAe,cAAc,MACT,CAAC,cACnC,kBAAkB,cAAAC,QAAM,WAAW,m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AAAA,QACA;AAAA,UACE,YAAY;AAAA,UACZ,SAAS;AAAA;AAAA,UAET,eAAe;AAAA,QACjB;AAAA,MACF;AAGA,aAAI,IAAI,UAAU,cAChB,uBAAU,IAAI,UAAU,KAAK,OAC7B,wBAAW,IAAI,UAAU,KAAK,IAGzB,IAAI;AAAA,IACb;AAEA,UAAM,QAAQ,SAAS,EAAE,GAAG,WAAW,OAAO,kBAAkB,CAAC,GAC3D,UAAU,OAAO,OACjB,mBAAmB,kBAAM,oBAAoB,KAAK,OAAO,UAAU,EAAK;AAE9E,wCAAU,MAAM;AACd,UAAK;AAEL,eAAO,cAAc,YAAY,GAAG,UAAU,CAAC,UAAU;AACvD,gBAAM,YAAY,cAAc,SAAS,KAAK,GACxC,kBAAkB,oBAAoB,IAAI,cAAc,WAAW,GACnE,OAAO,QAAQ,SAEf,WAAW,SAAS,EAAE,OAAO,UAAU,CAAC,EAAE;AAEhD,cAAI,YAAY,gBAAgB,aAAa;AAC3C,kBAAM,wBACJ,iBAAiB,SAAS,WACtB;AAAA,cACE,MAAM;AAAA,cACN,WAAW,iBAAiB,YAAY,KAAK;AAAA,YAC/C,IACA,iBAAiB,SAAS,WACxB,EAAE,MAAM,SAAS,UAAU,EAAE,IAC7B;AAAA,cACE,MAAM;AAAA,cACN,GAAI;AAAA,YACN;AAER,oBAAQ,MAAM,UAAiB,qBAAqB;AAAA,UACtD;AAAA,QACF,CAAC;AAAA,IACH,GAAG,CAAC,aAAa,CAAC,GAEX,4CAAC,WAAS,GAAG,kBAAkB,KAAK,cAAc;AAAA,EAC3D,CAAC;AAED,mBAAU,gBAAmB,IAEtB;AACT;",
|
|
5
5
|
"names": ["import_react", "React", "animationOptions", "doAnimate", "props"]
|
|
6
6
|
}
|
|
@@ -53,19 +53,25 @@ function createAnimations(animationsProp) {
|
|
|
53
53
|
presenceContext,
|
|
54
54
|
animationKey,
|
|
55
55
|
styleKey
|
|
56
|
-
]), runAnimation = function(
|
|
57
|
-
if (
|
|
58
|
-
if ((0, import_core.fixStyles)(
|
|
59
|
-
lastAnimationStyle.current =
|
|
56
|
+
]), runAnimation = function(nextStyle, animationOptions2) {
|
|
57
|
+
if (nextStyle && stateRef.current.host instanceof HTMLElement) {
|
|
58
|
+
if ((0, import_core.fixStyles)(nextStyle), (0, import_core.styleToCSS)(nextStyle), !lastAnimationStyle.current) {
|
|
59
|
+
lastAnimationStyle.current = nextStyle, controls.current = animate(scope.current, nextStyle, {
|
|
60
60
|
duration: 0,
|
|
61
61
|
type: "tween"
|
|
62
|
-
}), controls.current.complete();
|
|
62
|
+
}), controls.current.complete(), scope.animations = [];
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
var diff = {};
|
|
66
|
-
for (var key2 in
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
for (var key2 in nextStyle)
|
|
67
|
+
nextStyle[key2] !== lastAnimationStyle.current[key2] && (diff[key2] = nextStyle[key2]);
|
|
68
|
+
process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-motion] animate (", JSON.stringify(diff, null, 2) + ")"), scope.animations = scope.animations.filter(function(x) {
|
|
69
|
+
try {
|
|
70
|
+
return x.state !== "finished" && x.state !== "idle";
|
|
71
|
+
} catch {
|
|
72
|
+
return !0;
|
|
73
|
+
}
|
|
74
|
+
}), controls.current = animate(scope.current, diff, animationOptions2), lastAnimationStyle.current = nextStyle;
|
|
69
75
|
}
|
|
70
76
|
};
|
|
71
77
|
return useStyleEmitter == null || useStyleEmitter(function(nextStyle) {
|
|
@@ -80,12 +86,7 @@ function createAnimations(animationsProp) {
|
|
|
80
86
|
}, [
|
|
81
87
|
JSON.stringify(doAnimate),
|
|
82
88
|
lastAnimationStyle
|
|
83
|
-
]), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-motion](", JSON.stringify(
|
|
84
|
-
doAnimate,
|
|
85
|
-
dontAnimate,
|
|
86
|
-
animationOptions,
|
|
87
|
-
props
|
|
88
|
-
}), {
|
|
89
|
+
]), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-motion] render (", JSON.stringify(dontAnimate, null, 2) + ")"), {
|
|
89
90
|
style: dontAnimate,
|
|
90
91
|
ref: scope,
|
|
91
92
|
tag: "div"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createAnimations.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;uDAAA,cAaO,0BACP,sBAA4D,kCAC5D,eAQO,yBACPA,gBAA+E,2BAYzEC,sBAAsB,oBAAIC,QAAAA;AAEzB,SAASC,iBACdC,gBAAiB;AAKjB,MAAMC,aAAgB,CAAC;AACvB,WAAWC,OAAOF;AAChBC,eAAWC,GAAAA,IAAO;MAChBC,MAAM;MACN,GAAGH,eAAeE,GAAAA;IACpB;AAGF,SAAO;;IAELE,MAAMC;IACNC,MAAMC;IACNC,eAAe;IACfC,iBAAiB;IACjBC,gBAAgB;IAChBC,gBAAgB;IAChBV;IACAW;IACAC;IAEAC,eAAe,SAACC,gBAAAA;AACd,UAAM,EAAEC,OAAOC,OAAOC,gBAAgBC,UAAUC,gBAAe,IAAKL,gBAE9DM,eAAeC,MAAMC,QAAQP,MAAMQ,SAAS,IAC9CR,MAAMQ,UAAU,CAAA,IAChBR,MAAMQ,WAEJC,cAAcP,eAAeQ,cAAc,IAC3CC,mBAAmBF,eAAe,CAACJ,cACnCO,kBAAkBC,cAAAA,QAAMC,WAAWC,mCAAAA,GAEnC,CAACC,OAAOC,OAAAA,QAAWC,yBAAAA,GACnBC,yBAAqBC,sBAAsB,IAAA,GAC3CC,eAAWD,sBAAiD,IAAA,GAC5DE,WAAWC,KAAKC,UAAUvB,KAAAA,GAE1B,EAAEwB,aAAaC,WAAWC,iBAAgB,QAAKC,uBAAQ,WAAA;AAC3D,YAAMC,uBAAuBC,uBAC3B9B,OACAC,OACAU,gBAAAA;AAEF,eAAOkB;MACT,GAAG;QAACjB;QAAiBP;QAAciB;OAAS,GAItCS,eAAe,SACnBC,
|
|
5
|
-
"names": ["import_react", "MotionValueStrategy", "WeakMap", "createAnimations", "animationsProp", "animations", "key", "type", "View", "MotionView", "Text", "MotionText", "isReactNative", "supportsCSSVars", "needsWebStyles", "avoidReRenders", "usePresence", "ResetPresence", "useAnimations", "animationProps", "props", "style", "componentState", "stateRef", "useStyleEmitter", "animationKey", "Array", "isArray", "animation", "isHydrating", "unmounted", "disableAnimation", "presenceContext", "React", "useContext", "PresenceContext", "scope", "animate", "useAnimate", "lastAnimationStyle", "useRef", "controls", "styleKey", "JSON", "stringify", "dontAnimate", "doAnimate", "animationOptions", "useMemo", "motionAnimationState", "getMotionAnimatedProps", "runAnimation", "
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;uDAAA,cAaO,0BACP,sBAA4D,kCAC5D,eAQO,yBACPA,gBAA+E,2BAYzEC,sBAAsB,oBAAIC,QAAAA;AAEzB,SAASC,iBACdC,gBAAiB;AAKjB,MAAMC,aAAgB,CAAC;AACvB,WAAWC,OAAOF;AAChBC,eAAWC,GAAAA,IAAO;MAChBC,MAAM;MACN,GAAGH,eAAeE,GAAAA;IACpB;AAGF,SAAO;;IAELE,MAAMC;IACNC,MAAMC;IACNC,eAAe;IACfC,iBAAiB;IACjBC,gBAAgB;IAChBC,gBAAgB;IAChBV;IACAW;IACAC;IAEAC,eAAe,SAACC,gBAAAA;AACd,UAAM,EAAEC,OAAOC,OAAOC,gBAAgBC,UAAUC,gBAAe,IAAKL,gBAE9DM,eAAeC,MAAMC,QAAQP,MAAMQ,SAAS,IAC9CR,MAAMQ,UAAU,CAAA,IAChBR,MAAMQ,WAEJC,cAAcP,eAAeQ,cAAc,IAC3CC,mBAAmBF,eAAe,CAACJ,cACnCO,kBAAkBC,cAAAA,QAAMC,WAAWC,mCAAAA,GAEnC,CAACC,OAAOC,OAAAA,QAAWC,yBAAAA,GACnBC,yBAA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AiB5I,UAAS,WACxB;cAAEA,MAAM;cAASmD,UAAU;YAAE,IAC7B;cACEnD,MAAM;cACN,GAAI4I;YACN;AAER9G,oBAAQ+G,MAAMC,UAAiBC,qBAAAA;UACjC;QACF,CAAA;IACF,GAAG;MAACnB;KAAc,GAEX,uCAAAoB,KAACP,SAAAA;MAAS,GAAGC;MAAkB1E,KAAKuD;;EAC7C,CAAA;AAEAP,mBAAU,gBAAmB,IAEtBA;AACT;",
|
|
5
|
+
"names": ["import_react", "MotionValueStrategy", "WeakMap", "createAnimations", "animationsProp", "animations", "key", "type", "View", "MotionView", "Text", "MotionText", "isReactNative", "supportsCSSVars", "needsWebStyles", "avoidReRenders", "usePresence", "ResetPresence", "useAnimations", "animationProps", "props", "style", "componentState", "stateRef", "useStyleEmitter", "animationKey", "Array", "isArray", "animation", "isHydrating", "unmounted", "disableAnimation", "presenceContext", "React", "useContext", "PresenceContext", "scope", "animate", "useAnimate", "lastAnimationStyle", "useRef", "controls", "styleKey", "JSON", "stringify", "dontAnimate", "doAnimate", "animationOptions", "useMemo", "motionAnimationState", "getMotionAnimatedProps", "runAnimation", "nextStyle", "current", "host", "HTMLElement", "fixStyles", "styleToCSS", "duration", "complete", "diff", "process", "env", "NODE_ENV", "console", "info", "filter", "x", "state", "useEffect", "useLayoutEffect", "ref", "tag", "useAnimatedNumber", "initial", "motionValue", "useMotionValue", "getInstance", "getValue", "get", "setValue", "next", "config", "onFinish", "set", "unsubscribe", "on", "value", "Math", "abs", "stop", "useAnimatedNumberReaction", "onValue", "instance", "useMotionValueEvent", "useAnimatedNumberStyle", "val", "getStyleProp", "getStyleRef", "getStyle", "cur", "disable", "animationPropToAnimationConfig", "animateOnly", "disableAnimationProps", "has", "includes", "animationProp", "defaultAnimationKey", "specificAnimations", "default", "Object", "fromEntries", "keys", "flatMap", "Set", "createMotionView", "defaultTag", "isText", "Component", "forwardRef", "propsIn", "hooks", "forwardedRef", "propsRest", "hostRef", "composedRefs", "useComposedRefs", "_", "useThemeWithState", "styles", "animatedStyle", "nonAnimatedStyles", "find", "getProps", "out", "getSplitStyles", "staticConfig", "theme", "name", "isAnimated", "noClass", "resolveValues", "viewProps", "Element", "transformedProps", "usePropsTransform", "animationConfig", "node", "webStyle", "motionAnimationConfig", "_jsx"]
|
|
6
6
|
}
|
|
@@ -40,20 +40,29 @@ function createAnimations(animationsProp) {
|
|
|
40
40
|
props,
|
|
41
41
|
style,
|
|
42
42
|
disableAnimation
|
|
43
|
-
), [presenceContext, animationKey, styleKey]), runAnimation = (
|
|
44
|
-
if (!
|
|
43
|
+
), [presenceContext, animationKey, styleKey]), runAnimation = (nextStyle, animationOptions2) => {
|
|
44
|
+
if (!nextStyle || !(stateRef.current.host instanceof HTMLElement))
|
|
45
45
|
return;
|
|
46
|
-
if (fixStyles(
|
|
47
|
-
lastAnimationStyle.current =
|
|
46
|
+
if (fixStyles(nextStyle), styleToCSS(nextStyle), !lastAnimationStyle.current) {
|
|
47
|
+
lastAnimationStyle.current = nextStyle, controls.current = animate(scope.current, nextStyle, {
|
|
48
48
|
duration: 0,
|
|
49
49
|
type: "tween"
|
|
50
|
-
}), controls.current.complete();
|
|
50
|
+
}), controls.current.complete(), scope.animations = [];
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
const diff = {};
|
|
54
|
-
for (const key in
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
for (const key in nextStyle)
|
|
55
|
+
nextStyle[key] !== lastAnimationStyle.current[key] && (diff[key] = nextStyle[key]);
|
|
56
|
+
process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info(
|
|
57
|
+
"[animations-motion] animate (",
|
|
58
|
+
JSON.stringify(diff, null, 2) + ")"
|
|
59
|
+
), scope.animations = scope.animations.filter((x) => {
|
|
60
|
+
try {
|
|
61
|
+
return x.state !== "finished" && x.state !== "idle";
|
|
62
|
+
} catch {
|
|
63
|
+
return !0;
|
|
64
|
+
}
|
|
65
|
+
}), controls.current = animate(scope.current, diff, animationOptions2), lastAnimationStyle.current = nextStyle;
|
|
57
66
|
};
|
|
58
67
|
return useStyleEmitter?.((nextStyle) => {
|
|
59
68
|
const { doAnimate: doAnimate2, animationOptions: animationOptions2 } = getMotionAnimatedProps(
|
|
@@ -66,12 +75,10 @@ function createAnimations(animationsProp) {
|
|
|
66
75
|
lastAnimationStyle.current = null;
|
|
67
76
|
}, []), useLayoutEffect(() => {
|
|
68
77
|
doAnimate && runAnimation(doAnimate, animationOptions);
|
|
69
|
-
}, [JSON.stringify(doAnimate), lastAnimationStyle]), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info(
|
|
70
|
-
|
|
71
|
-
dontAnimate,
|
|
72
|
-
|
|
73
|
-
props
|
|
74
|
-
}), {
|
|
78
|
+
}, [JSON.stringify(doAnimate), lastAnimationStyle]), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info(
|
|
79
|
+
"[animations-motion] render (",
|
|
80
|
+
JSON.stringify(dontAnimate, null, 2) + ")"
|
|
81
|
+
), {
|
|
75
82
|
style: dontAnimate,
|
|
76
83
|
ref: scope,
|
|
77
84
|
tag: "div"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createAnimations.tsx"],
|
|
4
|
-
"mappings": "AAAA;AAAA,EAIE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB,eAAe,mBAAmB;AAC5D;AAAA,EAIE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,OAAO,SAAS,YAAY,WAAW,iBAAiB,SAAS,cAAc;
|
|
4
|
+
"mappings": "AAAA;AAAA,EAIE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB,eAAe,mBAAmB;AAC5D;AAAA,E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gB,aAAa;AAC3C,kBAAM,wBACJ,iBAAiB,SAAS,WACtB;AAAA,cACE,MAAM;AAAA,cACN,WAAW,iBAAiB,YAAY,KAAK;AAAA,YAC/C,IACA,iBAAiB,SAAS,WACxB,EAAE,MAAM,SAAS,UAAU,EAAE,IAC7B;AAAA,cACE,MAAM;AAAA,cACN,GAAI;AAAA,YACN;AAER,oBAAQ,MAAM,UAAiB,qBAAqB;AAAA,UACtD;AAAA,QACF,CAAC;AAAA,IACH,GAAG,CAAC,aAAa,CAAC,GAEX,oBAAC,WAAS,GAAG,kBAAkB,KAAK,cAAc;AAAA,EAC3D,CAAC;AAED,mBAAU,gBAAmB,IAEtB;AACT;",
|
|
5
5
|
"names": ["animationOptions", "doAnimate", "props"]
|
|
6
6
|
}
|
|
@@ -41,18 +41,24 @@ function createAnimations(animationsProp) {
|
|
|
41
41
|
doAnimate,
|
|
42
42
|
animationOptions
|
|
43
43
|
} = useMemo(() => getMotionAnimatedProps(props, style, disableAnimation), [presenceContext, animationKey, styleKey]),
|
|
44
|
-
runAnimation = (
|
|
45
|
-
if (!
|
|
46
|
-
if (fixStyles(
|
|
47
|
-
lastAnimationStyle.current =
|
|
44
|
+
runAnimation = (nextStyle, animationOptions2) => {
|
|
45
|
+
if (!nextStyle || !(stateRef.current.host instanceof HTMLElement)) return;
|
|
46
|
+
if (fixStyles(nextStyle), styleToCSS(nextStyle), !lastAnimationStyle.current) {
|
|
47
|
+
lastAnimationStyle.current = nextStyle, controls.current = animate(scope.current, nextStyle, {
|
|
48
48
|
duration: 0,
|
|
49
49
|
type: "tween"
|
|
50
|
-
}), controls.current.complete();
|
|
50
|
+
}), controls.current.complete(), scope.animations = [];
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
const diff = {};
|
|
54
|
-
for (const key in
|
|
55
|
-
|
|
54
|
+
for (const key in nextStyle) nextStyle[key] !== lastAnimationStyle.current[key] && (diff[key] = nextStyle[key]);
|
|
55
|
+
process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-motion] animate (", JSON.stringify(diff, null, 2) + ")"), scope.animations = scope.animations.filter(x => {
|
|
56
|
+
try {
|
|
57
|
+
return x.state !== "finished" && x.state !== "idle";
|
|
58
|
+
} catch {
|
|
59
|
+
return !0;
|
|
60
|
+
}
|
|
61
|
+
}), controls.current = animate(scope.current, diff, animationOptions2), lastAnimationStyle.current = nextStyle;
|
|
56
62
|
};
|
|
57
63
|
return useStyleEmitter?.(nextStyle => {
|
|
58
64
|
const {
|
|
@@ -64,12 +70,7 @@ function createAnimations(animationsProp) {
|
|
|
64
70
|
lastAnimationStyle.current = null;
|
|
65
71
|
}, []), useLayoutEffect(() => {
|
|
66
72
|
doAnimate && runAnimation(doAnimate, animationOptions);
|
|
67
|
-
}, [JSON.stringify(doAnimate), lastAnimationStyle]), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-motion](", JSON.stringify(
|
|
68
|
-
doAnimate,
|
|
69
|
-
dontAnimate,
|
|
70
|
-
animationOptions,
|
|
71
|
-
props
|
|
72
|
-
}), {
|
|
73
|
+
}, [JSON.stringify(doAnimate), lastAnimationStyle]), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-motion] render (", JSON.stringify(dontAnimate, null, 2) + ")"), {
|
|
73
74
|
style: dontAnimate,
|
|
74
75
|
ref: scope,
|
|
75
76
|
tag: "div"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fixStyles","getSplitStyles","hooks","styleToCSS","Text","useComposedRefs","useThemeWithState","View","PresenceContext","ResetPresence","usePresence","useAnimate","useMotionValue","useMotionValueEvent","React","forwardRef","useEffect","useLayoutEffect","useMemo","useRef","jsx","MotionValueStrategy","WeakMap","createAnimations","animationsProp","animations","key","type","MotionView","MotionText","isReactNative","supportsCSSVars","needsWebStyles","avoidReRenders","useAnimations","animationProps","props","style","componentState","stateRef","useStyleEmitter","animationKey","Array","isArray","animation","disableAnimation","unmounted","presenceContext","useContext","scope","animate","lastAnimationStyle","controls","styleKey","JSON","stringify","dontAnimate","doAnimate","animationOptions","getMotionAnimatedProps","runAnimation","
|
|
1
|
+
{"version":3,"names":["fixStyles","getSplitStyles","hooks","styleToCSS","Text","useComposedRefs","useThemeWithState","View","PresenceContext","ResetPresence","usePresence","useAnimate","useMotionValue","useMotionValueEvent","React","forwardRef","useEffect","useLayoutEffect","useMemo","useRef","jsx","MotionValueStrategy","WeakMap","createAnimations","animationsProp","animations","key","type","MotionView","MotionText","isReactNative","supportsCSSVars","needsWebStyles","avoidReRenders","useAnimations","animationProps","props","style","componentState","stateRef","useStyleEmitter","animationKey","Array","isArray","animation","disableAnimation","unmounted","presenceContext","useContext","scope","animate","lastAnimationStyle","controls","styleKey","JSON","stringify","dontAnimate","doAnimate","animationOptions","getMotionAnimatedProps","runAnimation","nextStyle","animationOptions2","current","host","HTMLElement","duration","complete","diff","process","env","NODE_ENV","debug","console","info","filter","x","state","doAnimate2","ref","tag","useAnimatedNumber","initial","motionValue","getInstance","getValue","get","setValue","next","config","onFinish","set","unsubscribe","on","value","Math","abs","stop","useAnimatedNumberReaction","onValue","instance","useAnimatedNumberStyle","val","getStyleProp","getStyleRef","getStyle","cur","disable","animationPropToAnimationConfig","animateOnly","disableAnimationProps","has","includes","animationProp","defaultAnimationKey","specificAnimations","default","Object","fromEntries","keys","flatMap","Set","createMotionView","defaultTag","isText","Component","propsIn","forwardedRef","propsRest","hostRef","composedRefs","_","styles","animatedStyle","nonAnimatedStyles","find","getProps","props2","out","staticConfig","theme","name","isAnimated","noClass","resolveValues","viewProps","Element","transformedProps","usePropsTransform","animationConfig","node","webStyle","motionAnimationConfig","acceptTagProp"],"sources":["../../src/createAnimations.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAIEA,SAAA,EACAC,cAAA,EACAC,KAAA,EACAC,UAAA,EACAC,IAAA,EAEAC,eAAA,EACAC,iBAAA,EACAC,IAAA,QACK;AACP,SAASC,eAAA,EAAiBC,aAAA,E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WmF,eAAA,EAAiBnF,QAAA,IAAY,KAAK;YAC/C,IACAmF,eAAA,EAAiB1H,IAAA,KAAS,WACxB;cAAEA,IAAA,EAAM;cAASuC,QAAA,EAAU;YAAE,IAC7B;cACEvC,IAAA,EAAM;cACN,GAAI0H;YACN;YAERnG,OAAA,CAAQoG,IAAA,EAAMC,QAAA,EAAiBC,qBAAqB;UACtD;QACF,CAAC;MACH,GAAG,CAACnB,aAAa,CAAC,GAEX,eAAAjH,GAAA,CAAC8H,OAAA;QAAS,GAAGC,gBAAA;QAAkBpE,GAAA,EAAKmD;MAAA,CAAc;IAC3D,CAAC;EAED,OAAAL,SAAA,CAAU4B,aAAA,GAAmB,IAEtB5B,SAAA;AACT","ignoreList":[]}
|
|
@@ -45,18 +45,24 @@ function createAnimations(animationsProp) {
|
|
|
45
45
|
var motionAnimationState = getMotionAnimatedProps(props, style, disableAnimation);
|
|
46
46
|
return motionAnimationState;
|
|
47
47
|
}, [presenceContext, animationKey, styleKey]),
|
|
48
|
-
runAnimation = function (
|
|
49
|
-
if (
|
|
50
|
-
if (fixStyles(
|
|
51
|
-
lastAnimationStyle.current =
|
|
48
|
+
runAnimation = function (nextStyle, animationOptions2) {
|
|
49
|
+
if (nextStyle && stateRef.current.host instanceof HTMLElement) {
|
|
50
|
+
if (fixStyles(nextStyle), styleToCSS(nextStyle), !lastAnimationStyle.current) {
|
|
51
|
+
lastAnimationStyle.current = nextStyle, controls.current = animate(scope.current, nextStyle, {
|
|
52
52
|
duration: 0,
|
|
53
53
|
type: "tween"
|
|
54
|
-
}), controls.current.complete();
|
|
54
|
+
}), controls.current.complete(), scope.animations = [];
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
var diff = {};
|
|
58
|
-
for (var key2 in
|
|
59
|
-
|
|
58
|
+
for (var key2 in nextStyle) nextStyle[key2] !== lastAnimationStyle.current[key2] && (diff[key2] = nextStyle[key2]);
|
|
59
|
+
process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-motion] animate (", JSON.stringify(diff, null, 2) + ")"), scope.animations = scope.animations.filter(function (x) {
|
|
60
|
+
try {
|
|
61
|
+
return x.state !== "finished" && x.state !== "idle";
|
|
62
|
+
} catch {
|
|
63
|
+
return !0;
|
|
64
|
+
}
|
|
65
|
+
}), controls.current = animate(scope.current, diff, animationOptions2), lastAnimationStyle.current = nextStyle;
|
|
60
66
|
}
|
|
61
67
|
};
|
|
62
68
|
return useStyleEmitter?.(function (nextStyle) {
|
|
@@ -71,12 +77,7 @@ function createAnimations(animationsProp) {
|
|
|
71
77
|
};
|
|
72
78
|
}, []), useLayoutEffect(function () {
|
|
73
79
|
doAnimate && runAnimation(doAnimate, animationOptions);
|
|
74
|
-
}, [JSON.stringify(doAnimate), lastAnimationStyle]), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-motion](", JSON.stringify(
|
|
75
|
-
doAnimate,
|
|
76
|
-
dontAnimate,
|
|
77
|
-
animationOptions,
|
|
78
|
-
props
|
|
79
|
-
}), {
|
|
80
|
+
}, [JSON.stringify(doAnimate), lastAnimationStyle]), process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("[animations-motion] render (", JSON.stringify(dontAnimate, null, 2) + ")"), {
|
|
80
81
|
style: dontAnimate,
|
|
81
82
|
ref: scope,
|
|
82
83
|
tag: "div"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["jsx","_jsx","fixStyles","getSplitStyles","hooks","styleToCSS","Text","useComposedRefs","useThemeWithState","View","PresenceContext","ResetPresence","usePresence","useAnimate","useMotionValue","useMotionValueEvent","React","forwardRef","useEffect","useLayoutEffect","useMemo","useRef","MotionValueStrategy","WeakMap","createAnimations","animationsProp","animations","key","type","MotionView","MotionText","isReactNative","supportsCSSVars","needsWebStyles","avoidReRenders","useAnimations","animationProps","props","style","componentState","stateRef","useStyleEmitter","animationKey","Array","isArray","animation","isHydrating","unmounted","disableAnimation","presenceContext","useContext","scope","animate","lastAnimationStyle","controls","styleKey","JSON","stringify","dontAnimate","doAnimate","animationOptions","motionAnimationState","getMotionAnimatedProps","runAnimation","
|
|
1
|
+
{"version":3,"names":["jsx","_jsx","fixStyles","getSplitStyles","hooks","styleToCSS","Text","useComposedRefs","useThemeWithState","View","PresenceContext","ResetPresence","usePresence","useAnimate","useMotionValue","useMotionValueEvent","React","forwardRef","useEffect","useLayoutEffect","useMemo","useRef","MotionValueStrategy","WeakMap","createAnimations","animationsProp","animations","key","type","MotionView","MotionText","isReactNative","supportsCSSVars","needsWebStyles","avoidReRenders","useAnimations","animationProps","props","style","componentState","stateRef","useStyleEmitter","animationKey","Array","isArray","animation","isHydrating","unmounted","disableAnimation","presenceContext","useContext","scope","animate","lastAnimationStyle","controls","styleKey","JSON","stringify","dontAnimate","doAnimate","animationOptions","motionAnimationState","getMotionAnimatedProps","runAnimation","nextStyle","animationOptions2","current","host","HTMLElement","duration","complete","diff","key2","process","env","NODE_ENV","debug","console","info","filter","x","state","doAnimate2","ref","tag","useAnimatedNumber","initial","motionValue","getInstance","getValue","get","setValue","next","config","arguments","length","onFinish","set","unsubscribe","on","value","Math","abs","stop","useAnimatedNumberReaction","param","onValue","instance","useAnimatedNumberStyle","val","getStyleProp","getStyleRef","getStyle","cur","disable","animationPropToAnimationConfig","animateOnly","disableAnimationProps","has","includes","animationProp","defaultAnimationKey","specificAnimations","default","Object","fromEntries","keys","flatMap","Set","createMotionView","defaultTag","isText","Component","propsIn","_hooks_usePropsTransform","forwardedRef","propsRest","hostRef","composedRefs","_","styles","animatedStyle","nonAnimatedStyles","find","getProps","props2","out","staticConfig","theme","name","isAnimated","noClass","resolveValues","viewProps","Element","transformedProps","usePropsTransform","call","animationConfig","node","webStyle","motionAnimationConfig"],"sources":["../../src/createAnimations.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAAAA,GAAA,IAAAC,IAAA;AAAA,SAIEC,SAAA,EAAAC,cAAA,EAAAC,KAAA,EAAAC,UAAA,EAAAC,IAAA,E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|
5
5
|
"license": "MIT",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tamagui/core": "1.129.
|
|
33
|
-
"@tamagui/use-presence": "1.129.
|
|
32
|
+
"@tamagui/core": "1.129.7",
|
|
33
|
+
"@tamagui/use-presence": "1.129.7",
|
|
34
34
|
"motion": "^12.19.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@tamagui/build": "1.129.
|
|
37
|
+
"@tamagui/build": "1.129.7",
|
|
38
38
|
"react": "*"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
package/src/createAnimations.tsx
CHANGED
|
@@ -90,39 +90,59 @@ export function createAnimations<A extends Record<string, AnimationConfig>>(
|
|
|
90
90
|
// const id = useId()
|
|
91
91
|
|
|
92
92
|
const runAnimation = (
|
|
93
|
-
|
|
93
|
+
nextStyle: Record<string, unknown> | null,
|
|
94
94
|
animationOptions: AnimationOptions | undefined
|
|
95
95
|
) => {
|
|
96
|
-
if (!
|
|
96
|
+
if (!nextStyle) return
|
|
97
97
|
if (!(stateRef.current.host instanceof HTMLElement)) {
|
|
98
98
|
return
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
// ideally this would just come from tamagui
|
|
102
|
-
fixStyles(
|
|
103
|
-
styleToCSS(
|
|
102
|
+
fixStyles(nextStyle)
|
|
103
|
+
styleToCSS(nextStyle)
|
|
104
104
|
|
|
105
105
|
if (!lastAnimationStyle.current) {
|
|
106
106
|
// console.log('first', id, animationStyle)
|
|
107
|
-
lastAnimationStyle.current =
|
|
108
|
-
controls.current = animate(scope.current,
|
|
107
|
+
lastAnimationStyle.current = nextStyle
|
|
108
|
+
controls.current = animate(scope.current, nextStyle, {
|
|
109
109
|
duration: 0,
|
|
110
110
|
type: 'tween',
|
|
111
111
|
})
|
|
112
112
|
controls.current.complete()
|
|
113
|
+
scope.animations = []
|
|
113
114
|
return
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
const diff = {}
|
|
117
|
-
for (const key in
|
|
118
|
-
if (
|
|
119
|
-
diff[key] =
|
|
118
|
+
for (const key in nextStyle) {
|
|
119
|
+
if (nextStyle[key] !== lastAnimationStyle.current[key]) {
|
|
120
|
+
diff[key] = nextStyle[key]
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
|
|
124
|
+
if (
|
|
125
|
+
process.env.NODE_ENV === 'development' &&
|
|
126
|
+
props['debug'] &&
|
|
127
|
+
props['debug'] !== 'profile'
|
|
128
|
+
) {
|
|
129
|
+
console.info(
|
|
130
|
+
`[animations-motion] animate (`,
|
|
131
|
+
JSON.stringify(diff, null, 2) + ')'
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// for some reason it keeps adding and never removes
|
|
136
|
+
scope.animations = scope.animations.filter((x) => {
|
|
137
|
+
try {
|
|
138
|
+
return x.state !== 'finished' && x.state !== 'idle'
|
|
139
|
+
} catch {
|
|
140
|
+
// it can error
|
|
141
|
+
return true
|
|
142
|
+
}
|
|
143
|
+
})
|
|
124
144
|
controls.current = animate(scope.current, diff, animationOptions)
|
|
125
|
-
lastAnimationStyle.current =
|
|
145
|
+
lastAnimationStyle.current = nextStyle
|
|
126
146
|
}
|
|
127
147
|
|
|
128
148
|
useStyleEmitter?.((nextStyle) => {
|
|
@@ -154,16 +174,12 @@ export function createAnimations<A extends Record<string, AnimationConfig>>(
|
|
|
154
174
|
props['debug'] &&
|
|
155
175
|
props['debug'] !== 'profile'
|
|
156
176
|
) {
|
|
157
|
-
console.info(
|
|
158
|
-
|
|
159
|
-
dontAnimate,
|
|
160
|
-
|
|
161
|
-
props,
|
|
162
|
-
})
|
|
177
|
+
console.info(
|
|
178
|
+
`[animations-motion] render (`,
|
|
179
|
+
JSON.stringify(dontAnimate, null, 2) + ')'
|
|
180
|
+
)
|
|
163
181
|
}
|
|
164
182
|
|
|
165
|
-
// console.log('render', id, scope)
|
|
166
|
-
|
|
167
183
|
return {
|
|
168
184
|
style: dontAnimate,
|
|
169
185
|
ref: scope,
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"src/createAnimations.tsx"
|
|
8
8
|
],
|
|
9
9
|
"sourcesContent": [
|
|
10
|
-
"import {\n type AnimatedNumberStrategy,\n type AnimationDriver,\n type AnimationProp,\n fixStyles,\n getSplitStyles,\n hooks,\n styleToCSS,\n Text,\n type UniversalAnimatedNumber,\n useComposedRefs,\n useThemeWithState,\n View,\n} from '@tamagui/core'\nimport { PresenceContext, ResetPresence, usePresence } from '@tamagui/use-presence'\nimport {\n type AnimationOptions,\n type AnimationPlaybackControlsWithThen,\n type MotionValue,\n useAnimate,\n useMotionValue,\n useMotionValueEvent,\n type ValueTransition,\n} from 'motion/react'\nimport React, { forwardRef, useEffect, useLayoutEffect, useMemo, useRef } from 'react'\n\n// TODO: useAnimatedNumber style could avoid re-rendering\n\ntype MotionAnimatedNumber = MotionValue<number>\ntype AnimationConfig = ValueTransition\n\ntype MotionAnimatedNumberStyle = {\n getStyle: (cur: number) => Record<string, unknown>\n motionValue: MotionValue<number>\n}\n\nconst MotionValueStrategy = new WeakMap<MotionValue, AnimatedNumberStrategy>()\n\nexport function createAnimations<A extends Record<string, AnimationConfig>>(\n animationsProp: A\n): AnimationDriver<A> {\n // normalize, it doesn't assume type: 'spring' even if damping etc there so we do that\n // which also matches the moti driver\n // @ts-expect-error avoid doing a spread for no reason, sub-constraint type issue\n const animations: A = {}\n for (const key in animationsProp) {\n animations[key] = {\n type: 'spring',\n ...animationsProp[key],\n }\n }\n\n return {\n // this is only used by Sheet basically for now to pass result of useAnimatedStyle to\n View: MotionView,\n Text: MotionText,\n isReactNative: false,\n supportsCSSVars: true,\n needsWebStyles: true,\n avoidReRenders: true,\n animations,\n usePresence,\n ResetPresence,\n\n useAnimations: (animationProps) => {\n const { props, style, componentState, stateRef, useStyleEmitter } = animationProps\n\n const animationKey = Array.isArray(props.animation)\n ? props.animation[0]\n : props.animation\n\n const isHydrating = componentState.unmounted === true\n const disableAnimation = isHydrating || !animationKey\n const presenceContext = React.useContext(PresenceContext)\n\n const [scope, animate] = useAnimate()\n const lastAnimationStyle = useRef<Object | null>(null)\n const controls = useRef<AnimationPlaybackControlsWithThen | null>(null)\n const styleKey = JSON.stringify(style)\n\n const { dontAnimate, doAnimate, animationOptions } = useMemo(() => {\n const motionAnimationState = getMotionAnimatedProps(\n props as any,\n style,\n disableAnimation\n )\n return motionAnimationState\n }, [presenceContext, animationKey, styleKey])\n\n // const id = useId()\n\n const runAnimation = (\n animationStyle: Record<string, unknown> | null,\n animationOptions: AnimationOptions | undefined\n ) => {\n if (!animationStyle) return\n if (!(stateRef.current.host instanceof HTMLElement)) {\n return\n }\n\n // ideally this would just come from tamagui\n fixStyles(animationStyle)\n styleToCSS(animationStyle)\n\n if (!lastAnimationStyle.current) {\n // console.log('first', id, animationStyle)\n lastAnimationStyle.current = animationStyle\n controls.current = animate(scope.current, animationStyle, {\n duration: 0,\n type: 'tween',\n })\n controls.current.complete()\n return\n }\n\n const diff = {}\n for (const key in animationStyle) {\n if (animationStyle[key] !== lastAnimationStyle.current[key]) {\n diff[key] = animationStyle[key]\n }\n }\n\n // console.log('animate', id, diff)\n controls.current = animate(scope.current, diff, animationOptions)\n lastAnimationStyle.current = animationStyle\n }\n\n useStyleEmitter?.((nextStyle) => {\n const { doAnimate, animationOptions } = getMotionAnimatedProps(\n props as any,\n nextStyle,\n disableAnimation\n )\n runAnimation(doAnimate, animationOptions)\n })\n\n // strict mode correctness fix, idk why i thought it would clear a useRef\n // before running strict? if you remove this you'll see the next\n // useLayoutEffect re-run and animate due to lastAnimationStyle.current\n // being set when in theory it should be clear\n useEffect(() => {\n return () => {\n lastAnimationStyle.current = null\n }\n }, [])\n\n useLayoutEffect(() => {\n if (!doAnimate) return\n runAnimation(doAnimate, animationOptions)\n }, [JSON.stringify(doAnimate), lastAnimationStyle])\n\n if (\n process.env.NODE_ENV === 'development' &&\n props['debug'] &&\n props['debug'] !== 'profile'\n ) {\n console.info(`[animations-motion](`, JSON.stringify(doAnimate, null, 2) + ')', {\n doAnimate,\n dontAnimate,\n animationOptions,\n props,\n })\n }\n\n // console.log('render', id, scope)\n\n return {\n style: dontAnimate,\n ref: scope,\n tag: 'div',\n }\n },\n\n useAnimatedNumber(initial): UniversalAnimatedNumber<MotionAnimatedNumber> {\n const motionValue = useMotionValue(initial)\n\n return React.useMemo(\n () => ({\n getInstance() {\n return motionValue\n },\n getValue() {\n return motionValue.get()\n },\n setValue(next, config = { type: 'spring' }, onFinish) {\n if (config.type === 'direct') {\n MotionValueStrategy.set(motionValue, {\n type: 'direct',\n })\n motionValue.set(next)\n onFinish?.()\n } else {\n MotionValueStrategy.set(motionValue, config)\n\n if (onFinish) {\n const unsubscribe = motionValue.on('change', (value) => {\n if (Math.abs(value - next) < 0.01) {\n unsubscribe()\n onFinish()\n }\n })\n }\n\n motionValue.set(next)\n // Motion doesn't have a direct onFinish callback, so we simulate it\n }\n },\n stop() {\n motionValue.stop()\n },\n }),\n [motionValue]\n )\n },\n\n useAnimatedNumberReaction({ value }, onValue) {\n const instance = value.getInstance() as MotionValue<number>\n useMotionValueEvent(instance, 'change', onValue)\n },\n\n useAnimatedNumberStyle(val, getStyleProp) {\n const motionValue = val.getInstance() as MotionValue<number>\n const getStyleRef = useRef<typeof getStyleProp>(getStyleProp)\n\n // we need to change useAnimatedNumberStyle to have dep args to be concurrent safe\n getStyleRef.current = getStyleProp\n\n // never changes\n return useMemo(() => {\n return {\n getStyle: (cur) => {\n return getStyleRef.current(cur)\n },\n motionValue,\n } satisfies MotionAnimatedNumberStyle\n }, [])\n },\n }\n\n function getMotionAnimatedProps(\n props: { animation: AnimationProp | null; animateOnly?: string[] },\n style: Record<string, unknown>,\n disable = false\n ) {\n if (disable) {\n return {\n dontAnimate: style,\n doAnimate: null,\n }\n }\n\n const animationOptions = animationPropToAnimationConfig(props.animation)\n\n let dontAnimate = {}\n let doAnimate: Record<string, unknown> | null = null\n\n const animateOnly = props.animateOnly as string[] | undefined\n for (const key in style) {\n const value = style[key]\n if (disableAnimationProps.has(key) || (animateOnly && !animateOnly.includes(key))) {\n dontAnimate[key] = value\n } else {\n doAnimate ||= {}\n doAnimate[key] = value\n }\n }\n\n return {\n dontAnimate,\n doAnimate,\n animationOptions,\n }\n }\n\n function animationPropToAnimationConfig(\n animationProp: AnimationProp | null\n ): AnimationOptions {\n let defaultAnimationKey = ''\n let specificAnimations = {}\n\n if (typeof animationProp === 'string') {\n defaultAnimationKey = animationProp\n } else if (Array.isArray(animationProp)) {\n if (typeof animationProp[0] === 'string') {\n defaultAnimationKey = animationProp[0]\n specificAnimations = animationProp[1]\n } else {\n specificAnimations = animationProp\n }\n }\n\n if (!defaultAnimationKey) {\n return {}\n }\n\n return {\n default: animations[defaultAnimationKey],\n ...Object.fromEntries(\n Object.keys(specificAnimations).flatMap((key) => {\n if (animations[key]) {\n return [[key, animations[key]]]\n }\n return []\n })\n ),\n }\n }\n}\n\n// sort of temporary\nconst disableAnimationProps = new Set<string>([\n 'alignContent',\n 'alignItems',\n 'backdropFilter',\n 'boxSizing',\n 'contain',\n 'display',\n 'flexBasis',\n 'flexDirection',\n 'flexShrink',\n 'justifyContent',\n 'maxHeight',\n 'maxWidth',\n 'minHeight',\n 'minWidth',\n 'overflow',\n 'pointerEvents',\n 'position',\n 'textWrap',\n])\n\nconst MotionView = createMotionView('div')\nconst MotionText = createMotionView('span')\n\nfunction createMotionView(defaultTag: string) {\n // return forwardRef((props: any, ref) => {\n // console.log('rendering?', props)\n // const Element = motion[props.tag || defaultTag]\n // return <Element ref={ref} {...props} />\n // })\n const isText = defaultTag === 'span'\n\n const Component = forwardRef((propsIn: any, ref) => {\n const { forwardedRef, animation, tag = defaultTag, style, ...propsRest } = propsIn\n const [scope, animate] = useAnimate()\n const hostRef = useRef<HTMLElement>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref, hostRef, scope)\n\n const stateRef = useRef<any>(null)\n if (!stateRef.current) {\n stateRef.current = {\n get host() {\n return hostRef.current\n },\n }\n }\n\n const [_, state] = useThemeWithState({})\n\n const styles = Array.isArray(style) ? style : [style]\n\n // we can assume just one animatedStyle max for now\n const [animatedStyle, nonAnimatedStyles] = (() => {\n return [\n styles.find((x) => x.getStyle) as MotionAnimatedNumberStyle | undefined,\n styles.filter((x) => !x.getStyle),\n ] as const\n })()\n\n function getProps(props: any) {\n const out = getSplitStyles(\n props,\n isText ? Text.staticConfig : View.staticConfig,\n state?.theme!,\n state?.name!,\n {\n unmounted: false,\n },\n {\n isAnimated: false,\n noClass: true,\n // noMergeStyle: true,\n resolveValues: 'auto',\n }\n )\n\n // we can definitely get rid of this here\n if (out.viewProps.style) {\n fixStyles(out.viewProps.style)\n styleToCSS(out.viewProps.style)\n }\n\n return out.viewProps\n }\n\n const props = getProps({ ...propsRest, style: nonAnimatedStyles })\n const Element = tag || 'div'\n const transformedProps = hooks.usePropsTransform?.(tag, props, stateRef, false)\n\n useEffect(() => {\n if (!animatedStyle) return\n\n return animatedStyle.motionValue.on('change', (value) => {\n const nextStyle = animatedStyle.getStyle(value)\n const animationConfig = MotionValueStrategy.get(animatedStyle.motionValue)\n const node = hostRef.current\n\n const webStyle = getProps({ style: nextStyle }).style\n\n if (webStyle && node instanceof HTMLElement) {\n const motionAnimationConfig =\n animationConfig?.type === 'timing'\n ? {\n type: 'tween',\n duration: (animationConfig?.duration || 0) / 1000,\n }\n : animationConfig?.type === 'direct'\n ? { type: 'tween', duration: 0 }\n : {\n type: 'spring',\n ...(animationConfig as any),\n }\n\n animate(node, webStyle as any, motionAnimationConfig)\n }\n })\n }, [animatedStyle])\n\n return <Element {...transformedProps} ref={composedRefs} />\n })\n\n Component['acceptTagProp'] = true\n\n return Component\n}\n"
|
|
10
|
+
"import {\n type AnimatedNumberStrategy,\n type AnimationDriver,\n type AnimationProp,\n fixStyles,\n getSplitStyles,\n hooks,\n styleToCSS,\n Text,\n type UniversalAnimatedNumber,\n useComposedRefs,\n useThemeWithState,\n View,\n} from '@tamagui/core'\nimport { PresenceContext, ResetPresence, usePresence } from '@tamagui/use-presence'\nimport {\n type AnimationOptions,\n type AnimationPlaybackControlsWithThen,\n type MotionValue,\n useAnimate,\n useMotionValue,\n useMotionValueEvent,\n type ValueTransition,\n} from 'motion/react'\nimport React, { forwardRef, useEffect, useLayoutEffect, useMemo, useRef } from 'react'\n\n// TODO: useAnimatedNumber style could avoid re-rendering\n\ntype MotionAnimatedNumber = MotionValue<number>\ntype AnimationConfig = ValueTransition\n\ntype MotionAnimatedNumberStyle = {\n getStyle: (cur: number) => Record<string, unknown>\n motionValue: MotionValue<number>\n}\n\nconst MotionValueStrategy = new WeakMap<MotionValue, AnimatedNumberStrategy>()\n\nexport function createAnimations<A extends Record<string, AnimationConfig>>(\n animationsProp: A\n): AnimationDriver<A> {\n // normalize, it doesn't assume type: 'spring' even if damping etc there so we do that\n // which also matches the moti driver\n // @ts-expect-error avoid doing a spread for no reason, sub-constraint type issue\n const animations: A = {}\n for (const key in animationsProp) {\n animations[key] = {\n type: 'spring',\n ...animationsProp[key],\n }\n }\n\n return {\n // this is only used by Sheet basically for now to pass result of useAnimatedStyle to\n View: MotionView,\n Text: MotionText,\n isReactNative: false,\n supportsCSSVars: true,\n needsWebStyles: true,\n avoidReRenders: true,\n animations,\n usePresence,\n ResetPresence,\n\n useAnimations: (animationProps) => {\n const { props, style, componentState, stateRef, useStyleEmitter } = animationProps\n\n const animationKey = Array.isArray(props.animation)\n ? props.animation[0]\n : props.animation\n\n const isHydrating = componentState.unmounted === true\n const disableAnimation = isHydrating || !animationKey\n const presenceContext = React.useContext(PresenceContext)\n\n const [scope, animate] = useAnimate()\n const lastAnimationStyle = useRef<Object | null>(null)\n const controls = useRef<AnimationPlaybackControlsWithThen | null>(null)\n const styleKey = JSON.stringify(style)\n\n const { dontAnimate, doAnimate, animationOptions } = useMemo(() => {\n const motionAnimationState = getMotionAnimatedProps(\n props as any,\n style,\n disableAnimation\n )\n return motionAnimationState\n }, [presenceContext, animationKey, styleKey])\n\n // const id = useId()\n\n const runAnimation = (\n nextStyle: Record<string, unknown> | null,\n animationOptions: AnimationOptions | undefined\n ) => {\n if (!nextStyle) return\n if (!(stateRef.current.host instanceof HTMLElement)) {\n return\n }\n\n // ideally this would just come from tamagui\n fixStyles(nextStyle)\n styleToCSS(nextStyle)\n\n if (!lastAnimationStyle.current) {\n // console.log('first', id, animationStyle)\n lastAnimationStyle.current = nextStyle\n controls.current = animate(scope.current, nextStyle, {\n duration: 0,\n type: 'tween',\n })\n controls.current.complete()\n scope.animations = []\n return\n }\n\n const diff = {}\n for (const key in nextStyle) {\n if (nextStyle[key] !== lastAnimationStyle.current[key]) {\n diff[key] = nextStyle[key]\n }\n }\n\n if (\n process.env.NODE_ENV === 'development' &&\n props['debug'] &&\n props['debug'] !== 'profile'\n ) {\n console.info(\n `[animations-motion] animate (`,\n JSON.stringify(diff, null, 2) + ')'\n )\n }\n\n // for some reason it keeps adding and never removes\n scope.animations = scope.animations.filter((x) => {\n try {\n return x.state !== 'finished' && x.state !== 'idle'\n } catch {\n // it can error\n return true\n }\n })\n controls.current = animate(scope.current, diff, animationOptions)\n lastAnimationStyle.current = nextStyle\n }\n\n useStyleEmitter?.((nextStyle) => {\n const { doAnimate, animationOptions } = getMotionAnimatedProps(\n props as any,\n nextStyle,\n disableAnimation\n )\n runAnimation(doAnimate, animationOptions)\n })\n\n // strict mode correctness fix, idk why i thought it would clear a useRef\n // before running strict? if you remove this you'll see the next\n // useLayoutEffect re-run and animate due to lastAnimationStyle.current\n // being set when in theory it should be clear\n useEffect(() => {\n return () => {\n lastAnimationStyle.current = null\n }\n }, [])\n\n useLayoutEffect(() => {\n if (!doAnimate) return\n runAnimation(doAnimate, animationOptions)\n }, [JSON.stringify(doAnimate), lastAnimationStyle])\n\n if (\n process.env.NODE_ENV === 'development' &&\n props['debug'] &&\n props['debug'] !== 'profile'\n ) {\n console.info(\n `[animations-motion] render (`,\n JSON.stringify(dontAnimate, null, 2) + ')'\n )\n }\n\n return {\n style: dontAnimate,\n ref: scope,\n tag: 'div',\n }\n },\n\n useAnimatedNumber(initial): UniversalAnimatedNumber<MotionAnimatedNumber> {\n const motionValue = useMotionValue(initial)\n\n return React.useMemo(\n () => ({\n getInstance() {\n return motionValue\n },\n getValue() {\n return motionValue.get()\n },\n setValue(next, config = { type: 'spring' }, onFinish) {\n if (config.type === 'direct') {\n MotionValueStrategy.set(motionValue, {\n type: 'direct',\n })\n motionValue.set(next)\n onFinish?.()\n } else {\n MotionValueStrategy.set(motionValue, config)\n\n if (onFinish) {\n const unsubscribe = motionValue.on('change', (value) => {\n if (Math.abs(value - next) < 0.01) {\n unsubscribe()\n onFinish()\n }\n })\n }\n\n motionValue.set(next)\n // Motion doesn't have a direct onFinish callback, so we simulate it\n }\n },\n stop() {\n motionValue.stop()\n },\n }),\n [motionValue]\n )\n },\n\n useAnimatedNumberReaction({ value }, onValue) {\n const instance = value.getInstance() as MotionValue<number>\n useMotionValueEvent(instance, 'change', onValue)\n },\n\n useAnimatedNumberStyle(val, getStyleProp) {\n const motionValue = val.getInstance() as MotionValue<number>\n const getStyleRef = useRef<typeof getStyleProp>(getStyleProp)\n\n // we need to change useAnimatedNumberStyle to have dep args to be concurrent safe\n getStyleRef.current = getStyleProp\n\n // never changes\n return useMemo(() => {\n return {\n getStyle: (cur) => {\n return getStyleRef.current(cur)\n },\n motionValue,\n } satisfies MotionAnimatedNumberStyle\n }, [])\n },\n }\n\n function getMotionAnimatedProps(\n props: { animation: AnimationProp | null; animateOnly?: string[] },\n style: Record<string, unknown>,\n disable = false\n ) {\n if (disable) {\n return {\n dontAnimate: style,\n doAnimate: null,\n }\n }\n\n const animationOptions = animationPropToAnimationConfig(props.animation)\n\n let dontAnimate = {}\n let doAnimate: Record<string, unknown> | null = null\n\n const animateOnly = props.animateOnly as string[] | undefined\n for (const key in style) {\n const value = style[key]\n if (disableAnimationProps.has(key) || (animateOnly && !animateOnly.includes(key))) {\n dontAnimate[key] = value\n } else {\n doAnimate ||= {}\n doAnimate[key] = value\n }\n }\n\n return {\n dontAnimate,\n doAnimate,\n animationOptions,\n }\n }\n\n function animationPropToAnimationConfig(\n animationProp: AnimationProp | null\n ): AnimationOptions {\n let defaultAnimationKey = ''\n let specificAnimations = {}\n\n if (typeof animationProp === 'string') {\n defaultAnimationKey = animationProp\n } else if (Array.isArray(animationProp)) {\n if (typeof animationProp[0] === 'string') {\n defaultAnimationKey = animationProp[0]\n specificAnimations = animationProp[1]\n } else {\n specificAnimations = animationProp\n }\n }\n\n if (!defaultAnimationKey) {\n return {}\n }\n\n return {\n default: animations[defaultAnimationKey],\n ...Object.fromEntries(\n Object.keys(specificAnimations).flatMap((key) => {\n if (animations[key]) {\n return [[key, animations[key]]]\n }\n return []\n })\n ),\n }\n }\n}\n\n// sort of temporary\nconst disableAnimationProps = new Set<string>([\n 'alignContent',\n 'alignItems',\n 'backdropFilter',\n 'boxSizing',\n 'contain',\n 'display',\n 'flexBasis',\n 'flexDirection',\n 'flexShrink',\n 'justifyContent',\n 'maxHeight',\n 'maxWidth',\n 'minHeight',\n 'minWidth',\n 'overflow',\n 'pointerEvents',\n 'position',\n 'textWrap',\n])\n\nconst MotionView = createMotionView('div')\nconst MotionText = createMotionView('span')\n\nfunction createMotionView(defaultTag: string) {\n // return forwardRef((props: any, ref) => {\n // console.log('rendering?', props)\n // const Element = motion[props.tag || defaultTag]\n // return <Element ref={ref} {...props} />\n // })\n const isText = defaultTag === 'span'\n\n const Component = forwardRef((propsIn: any, ref) => {\n const { forwardedRef, animation, tag = defaultTag, style, ...propsRest } = propsIn\n const [scope, animate] = useAnimate()\n const hostRef = useRef<HTMLElement>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref, hostRef, scope)\n\n const stateRef = useRef<any>(null)\n if (!stateRef.current) {\n stateRef.current = {\n get host() {\n return hostRef.current\n },\n }\n }\n\n const [_, state] = useThemeWithState({})\n\n const styles = Array.isArray(style) ? style : [style]\n\n // we can assume just one animatedStyle max for now\n const [animatedStyle, nonAnimatedStyles] = (() => {\n return [\n styles.find((x) => x.getStyle) as MotionAnimatedNumberStyle | undefined,\n styles.filter((x) => !x.getStyle),\n ] as const\n })()\n\n function getProps(props: any) {\n const out = getSplitStyles(\n props,\n isText ? Text.staticConfig : View.staticConfig,\n state?.theme!,\n state?.name!,\n {\n unmounted: false,\n },\n {\n isAnimated: false,\n noClass: true,\n // noMergeStyle: true,\n resolveValues: 'auto',\n }\n )\n\n // we can definitely get rid of this here\n if (out.viewProps.style) {\n fixStyles(out.viewProps.style)\n styleToCSS(out.viewProps.style)\n }\n\n return out.viewProps\n }\n\n const props = getProps({ ...propsRest, style: nonAnimatedStyles })\n const Element = tag || 'div'\n const transformedProps = hooks.usePropsTransform?.(tag, props, stateRef, false)\n\n useEffect(() => {\n if (!animatedStyle) return\n\n return animatedStyle.motionValue.on('change', (value) => {\n const nextStyle = animatedStyle.getStyle(value)\n const animationConfig = MotionValueStrategy.get(animatedStyle.motionValue)\n const node = hostRef.current\n\n const webStyle = getProps({ style: nextStyle }).style\n\n if (webStyle && node instanceof HTMLElement) {\n const motionAnimationConfig =\n animationConfig?.type === 'timing'\n ? {\n type: 'tween',\n duration: (animationConfig?.duration || 0) / 1000,\n }\n : animationConfig?.type === 'direct'\n ? { type: 'tween', duration: 0 }\n : {\n type: 'spring',\n ...(animationConfig as any),\n }\n\n animate(node, webStyle as any, motionAnimationConfig)\n }\n })\n }, [animatedStyle])\n\n return <Element {...transformedProps} ref={composedRefs} />\n })\n\n Component['acceptTagProp'] = true\n\n return Component\n}\n"
|
|
11
11
|
],
|
|
12
12
|
"version": 3
|
|
13
13
|
}
|