@tamagui/animations-moti 1.123.17 → 1.124.0
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 +44 -38
- package/dist/cjs/createAnimations.js +32 -28
- package/dist/cjs/createAnimations.js.map +2 -2
- package/dist/cjs/createAnimations.native.js +41 -31
- package/dist/cjs/createAnimations.native.js.map +2 -2
- package/dist/esm/createAnimations.js +33 -29
- package/dist/esm/createAnimations.js.map +2 -2
- package/dist/esm/createAnimations.mjs +45 -39
- package/dist/esm/createAnimations.mjs.map +1 -1
- package/dist/esm/createAnimations.native.js +42 -32
- package/dist/esm/createAnimations.native.js.map +2 -2
- package/package.json +4 -4
- package/src/createAnimations.tsx +72 -65
- package/types/createAnimations.d.ts.map +1 -1
|
@@ -57,9 +57,7 @@ function createTamaguiAnimatedComponent(defaultTag = "div") {
|
|
|
57
57
|
return hostRef.current;
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
|
-
const [{
|
|
61
|
-
state
|
|
62
|
-
}] = (0, import_web.useThemeWithState)({}),
|
|
60
|
+
const [_, state] = (0, import_web.useThemeWithState)({}),
|
|
63
61
|
props = (0, import_web.getSplitStyles)(propsRest, isText ? import_web.Text.staticConfig : import_web.View.staticConfig, state?.theme, state?.name, {
|
|
64
62
|
unmounted: !1
|
|
65
63
|
}, {
|
|
@@ -179,42 +177,50 @@ function createAnimations(animations) {
|
|
|
179
177
|
} = animationProps,
|
|
180
178
|
animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation,
|
|
181
179
|
isHydrating = componentState.unmounted === !0,
|
|
182
|
-
disableAnimation = isHydrating || !animationKey
|
|
183
|
-
let animate = {},
|
|
184
|
-
dontAnimate = {};
|
|
185
|
-
if (disableAnimation) dontAnimate = style;else {
|
|
186
|
-
const animateOnly = props.animateOnly;
|
|
187
|
-
for (const key in style) {
|
|
188
|
-
const value = style[key];
|
|
189
|
-
!onlyAnimateKeys[key] || value === "auto" || typeof value == "string" && value.startsWith("calc") || animateOnly && !animateOnly.includes(key) ? dontAnimate[key] = value : animate[key] = value;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
componentState.unmounted === "should-enter" && (dontAnimate = style);
|
|
193
|
-
const styles = animate,
|
|
194
|
-
isExiting = !!presence?.[1],
|
|
180
|
+
disableAnimation = isHydrating || !animationKey,
|
|
195
181
|
presenceContext = import_react.default.useContext(import_use_presence.PresenceContext),
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
182
|
+
{
|
|
183
|
+
dontAnimate,
|
|
184
|
+
motiProps
|
|
185
|
+
} = (0, import_react.useMemo)(() => {
|
|
186
|
+
let animate = {},
|
|
187
|
+
dontAnimate2 = {};
|
|
188
|
+
if (disableAnimation) dontAnimate2 = style;else {
|
|
189
|
+
const animateOnly = props.animateOnly;
|
|
190
|
+
for (const key in style) {
|
|
191
|
+
const value = style[key];
|
|
192
|
+
!onlyAnimateKeys[key] || value === "auto" || typeof value == "string" && value.startsWith("calc") || animateOnly && !animateOnly.includes(key) ? dontAnimate2[key] = value : animate[key] = value;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
componentState.unmounted === "should-enter" && (dontAnimate2 = style);
|
|
196
|
+
const styles = animate,
|
|
197
|
+
isExiting = !!presence?.[1],
|
|
198
|
+
usePresenceValue = presence || void 0;
|
|
199
|
+
let transition = isHydrating ? {
|
|
200
|
+
type: "transition",
|
|
201
|
+
duration: 0
|
|
202
|
+
} : animations[animationKey],
|
|
203
|
+
hasClonedTransition = !1;
|
|
204
|
+
if (Array.isArray(props.animation)) {
|
|
205
|
+
const config = props.animation[1];
|
|
206
|
+
if (config && typeof config == "object") for (const key in config) {
|
|
207
|
+
const val = config[key];
|
|
208
|
+
hasClonedTransition || (transition = Object.assign({}, transition), hasClonedTransition = !0), typeof val == "string" ? transition[key] = animations[val] : transition[key] = val;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
dontAnimate: dontAnimate2,
|
|
213
|
+
motiProps: {
|
|
214
|
+
animate: isExiting || componentState.unmounted === !0 ? {} : styles,
|
|
215
|
+
transition: componentState.unmounted ? {
|
|
216
|
+
duration: 0
|
|
217
|
+
} : transition,
|
|
218
|
+
usePresenceValue,
|
|
219
|
+
presenceContext,
|
|
220
|
+
exit: isExiting ? styles : void 0
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}, [animationKey, componentState.unmounted, JSON.stringify(style), presenceContext]),
|
|
218
224
|
moti = (0, import_author.useMotify)(motiProps);
|
|
219
225
|
return process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("useMotify(", JSON.stringify(motiProps, null, 2) + ")", {
|
|
220
226
|
"componentState.unmounted": componentState.unmounted,
|
|
@@ -35,7 +35,7 @@ function createTamaguiAnimatedComponent(defaultTag = "div") {
|
|
|
35
35
|
return hostRef.current;
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
-
const [
|
|
38
|
+
const [_, state] = (0, import_web.useThemeWithState)({}), props = (0, import_web.getSplitStyles)(
|
|
39
39
|
propsRest,
|
|
40
40
|
isText ? import_web.Text.staticConfig : import_web.View.staticConfig,
|
|
41
41
|
state?.theme,
|
|
@@ -150,35 +150,39 @@ function createAnimations(animations) {
|
|
|
150
150
|
return (0, import_react_native_reanimated.useAnimatedStyle)(() => getStyle(derivedValue.value), [val, getStyle, derivedValue, instance]);
|
|
151
151
|
},
|
|
152
152
|
useAnimations: (animationProps) => {
|
|
153
|
-
const { props, presence, style, componentState } = animationProps, animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation, isHydrating = componentState.unmounted === !0, disableAnimation = isHydrating || !animationKey
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
153
|
+
const { props, presence, style, componentState } = animationProps, animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation, isHydrating = componentState.unmounted === !0, disableAnimation = isHydrating || !animationKey, presenceContext = import_react.default.useContext(import_use_presence.PresenceContext), { dontAnimate, motiProps } = (0, import_react.useMemo)(() => {
|
|
154
|
+
let animate = {}, dontAnimate2 = {};
|
|
155
|
+
if (disableAnimation)
|
|
156
|
+
dontAnimate2 = style;
|
|
157
|
+
else {
|
|
158
|
+
const animateOnly = props.animateOnly;
|
|
159
|
+
for (const key in style) {
|
|
160
|
+
const value = style[key];
|
|
161
|
+
!onlyAnimateKeys[key] || value === "auto" || typeof value == "string" && value.startsWith("calc") || animateOnly && !animateOnly.includes(key) ? dontAnimate2[key] = value : animate[key] = value;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
componentState.unmounted === "should-enter" && (dontAnimate2 = style);
|
|
165
|
+
const styles = animate, isExiting = !!presence?.[1], usePresenceValue = presence || void 0;
|
|
166
|
+
let transition = isHydrating ? { type: "transition", duration: 0 } : animations[animationKey], hasClonedTransition = !1;
|
|
167
|
+
if (Array.isArray(props.animation)) {
|
|
168
|
+
const config = props.animation[1];
|
|
169
|
+
if (config && typeof config == "object")
|
|
170
|
+
for (const key in config) {
|
|
171
|
+
const val = config[key];
|
|
172
|
+
hasClonedTransition || (transition = Object.assign({}, transition), hasClonedTransition = !0), typeof val == "string" ? transition[key] = animations[val] : transition[key] = val;
|
|
173
|
+
}
|
|
162
174
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const val = config[key];
|
|
172
|
-
hasClonedTransition || (transition = Object.assign({}, transition), hasClonedTransition = !0), typeof val == "string" ? transition[key] = animations[val] : transition[key] = val;
|
|
175
|
+
return {
|
|
176
|
+
dontAnimate: dontAnimate2,
|
|
177
|
+
motiProps: {
|
|
178
|
+
animate: isExiting || componentState.unmounted === !0 ? {} : styles,
|
|
179
|
+
transition: componentState.unmounted ? { duration: 0 } : transition,
|
|
180
|
+
usePresenceValue,
|
|
181
|
+
presenceContext,
|
|
182
|
+
exit: isExiting ? styles : void 0
|
|
173
183
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
animate: isExiting || componentState.unmounted === !0 ? {} : styles,
|
|
177
|
-
transition: componentState.unmounted ? { duration: 0 } : transition,
|
|
178
|
-
usePresenceValue,
|
|
179
|
-
presenceContext,
|
|
180
|
-
exit: isExiting ? styles : void 0
|
|
181
|
-
}, moti = (0, import_author.useMotify)(motiProps);
|
|
184
|
+
};
|
|
185
|
+
}, [animationKey, componentState.unmounted, JSON.stringify(style), presenceContext]), moti = (0, import_author.useMotify)(motiProps);
|
|
182
186
|
return process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("useMotify(", JSON.stringify(motiProps, null, 2) + ")", {
|
|
183
187
|
"componentState.unmounted": componentState.unmounted,
|
|
184
188
|
motiProps,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createAnimations.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4D,kCAC5D,aAUO,yBAEP,gBAA0B,wBAE1B,
|
|
5
|
-
"names": ["Animated", "React"]
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA4D,kCAC5D,aAUO,yBAEP,gBAA0B,wBAE1B,eAAmD,2BAGnD,iCASO,6CA6CM;AAtCb,SAAS,+BAA+B,aAAa,OAAO;AAC1D,Q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;AAClC,gBAAM,SAAS,MAAM,UAAU,CAAC;AAChC,cAAI,UAAU,OAAO,UAAW;AAC9B,uBAAW,OAAO,QAAQ;AACxB,oBAAM,MAAM,OAAO,GAAG;AAItB,cAAK,wBACH,aAAa,OAAO,OAAO,CAAC,GAAG,UAAU,GACzC,sBAAsB,KAIpB,OAAO,OAAQ,WACjB,WAAW,GAAG,IAAI,WAAW,GAAG,IAEhC,WAAW,GAAG,IAAI;AAAA,YAEtB;AAAA,QAEJ;AAEA,eAAO;AAAA,UACL,aAAAA;AAAA,UACA,WAAW;AAAA,YACT,SAAS,aAAa,eAAe,cAAc,KAAO,CAAC,IAAI;AAAA,YAC/D,YAAY,eAAe,YAAY,EAAE,UAAU,EAAE,IAAI;AAAA,YACzD;AAAA,YACA;AAAA,YACA,MAAM,YAAY,SAAS;AAAA,UAC7B;AAAA,QACF;AAAA,MACF,GAAG,CAAC,cAAc,eAAe,WAAW,KAAK,UAAU,KAAK,GAAG,eAAe,CAAC,GAE7E,WAAO,yBAAU,SAAS;AAEhC,aACE,QAAQ,IAAI,aAAa,iBACzB,MAAM,SACN,MAAM,UAAa,aAEnB,QAAQ,KAAK,cAAc,KAAK,UAAU,WAAW,MAAM,CAAC,IAAI,KAAK;AAAA,QACnE,4BAA4B,eAAe;AAAA,QAC3C;AAAA,QACA;AAAA,QACA,OAAO,CAAC,aAAa,KAAK,KAAK;AAAA,MACjC,CAAC,GAGI;AAAA,QACL,OAAO,CAAC,aAAa,KAAK,KAAK;AAAA,MACjC;AAAA,IACF;AAAA,EACF;AACF;",
|
|
5
|
+
"names": ["Animated", "React", "dontAnimate"]
|
|
6
6
|
}
|
|
@@ -35,7 +35,7 @@ function createTamaguiAnimatedComponent() {
|
|
|
35
35
|
return hostRef.current;
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
-
var [
|
|
38
|
+
var [_, state] = (0, import_web.useThemeWithState)({}), result = (0, import_web.getSplitStyles)(propsRest, isText ? import_web.Text.staticConfig : import_web.View.staticConfig, state == null ? void 0 : state.theme, state == null ? void 0 : state.name, {
|
|
39
39
|
unmounted: !1
|
|
40
40
|
}, {
|
|
41
41
|
isAnimated: !1,
|
|
@@ -166,38 +166,48 @@ function createAnimations(animations) {
|
|
|
166
166
|
);
|
|
167
167
|
},
|
|
168
168
|
useAnimations: function(animationProps) {
|
|
169
|
-
var { props, presence, style, componentState } = animationProps, animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation, isHydrating = componentState.unmounted === !0, disableAnimation = isHydrating || !animationKey,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
var
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
componentState.unmounted === "should-enter" && (dontAnimate = style);
|
|
180
|
-
var styles = animate, isExiting = !!(presence != null && presence[1]), presenceContext = import_react.default.useContext(import_use_presence.PresenceContext), usePresenceValue = presence || void 0, transition = isHydrating ? {
|
|
181
|
-
type: "transition",
|
|
182
|
-
duration: 0
|
|
183
|
-
} : animations[animationKey], hasClonedTransition = !1;
|
|
184
|
-
if (Array.isArray(props.animation)) {
|
|
185
|
-
var config = props.animation[1];
|
|
186
|
-
if (config && typeof config == "object")
|
|
187
|
-
for (var key1 in config) {
|
|
188
|
-
var val = config[key1];
|
|
189
|
-
hasClonedTransition || (transition = Object.assign({}, transition), hasClonedTransition = !0), typeof val == "string" ? transition[key1] = animations[val] : transition[key1] = val;
|
|
169
|
+
var { props, presence, style, componentState } = animationProps, animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation, isHydrating = componentState.unmounted === !0, disableAnimation = isHydrating || !animationKey, presenceContext = import_react.default.useContext(import_use_presence.PresenceContext), { dontAnimate, motiProps } = (0, import_react.useMemo)(function() {
|
|
170
|
+
var animate = {}, dontAnimate2 = {};
|
|
171
|
+
if (disableAnimation)
|
|
172
|
+
dontAnimate2 = style;
|
|
173
|
+
else {
|
|
174
|
+
var animateOnly = props.animateOnly;
|
|
175
|
+
for (var key in style) {
|
|
176
|
+
var value = style[key];
|
|
177
|
+
!onlyAnimateKeys[key] || value === "auto" || typeof value == "string" && value.startsWith("calc") || animateOnly && !animateOnly.includes(key) ? dontAnimate2[key] = value : animate[key] = value;
|
|
190
178
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
animate
|
|
194
|
-
|
|
179
|
+
}
|
|
180
|
+
componentState.unmounted === "should-enter" && (dontAnimate2 = style);
|
|
181
|
+
var styles = animate, isExiting = !!(presence != null && presence[1]), usePresenceValue = presence || void 0, transition = isHydrating ? {
|
|
182
|
+
type: "transition",
|
|
195
183
|
duration: 0
|
|
196
|
-
} :
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
184
|
+
} : animations[animationKey], hasClonedTransition = !1;
|
|
185
|
+
if (Array.isArray(props.animation)) {
|
|
186
|
+
var config = props.animation[1];
|
|
187
|
+
if (config && typeof config == "object")
|
|
188
|
+
for (var key1 in config) {
|
|
189
|
+
var val = config[key1];
|
|
190
|
+
hasClonedTransition || (transition = Object.assign({}, transition), hasClonedTransition = !0), typeof val == "string" ? transition[key1] = animations[val] : transition[key1] = val;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
dontAnimate: dontAnimate2,
|
|
195
|
+
motiProps: {
|
|
196
|
+
animate: isExiting || componentState.unmounted === !0 ? {} : styles,
|
|
197
|
+
transition: componentState.unmounted ? {
|
|
198
|
+
duration: 0
|
|
199
|
+
} : transition,
|
|
200
|
+
usePresenceValue,
|
|
201
|
+
presenceContext,
|
|
202
|
+
exit: isExiting ? styles : void 0
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}, [
|
|
206
|
+
animationKey,
|
|
207
|
+
componentState.unmounted,
|
|
208
|
+
JSON.stringify(style),
|
|
209
|
+
presenceContext
|
|
210
|
+
]), moti = (0, import_author.useMotify)(motiProps);
|
|
201
211
|
return process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("useMotify(", JSON.stringify(motiProps, null, 2) + ")", {
|
|
202
212
|
"componentState.unmounted": componentState.unmounted,
|
|
203
213
|
motiProps,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/animations-moti/src/createAnimations.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;uDAAA,sBAA4D,kCAC5D,aAUO,yBAEP,gBAA0B,wBAE1B,
|
|
5
|
-
"names": ["createTamaguiAnimatedComponent", "defaultTag", "isText", "Component", "Animated", "createAnimatedComponent", "forwardRef", "propsIn", "ref", "hooks", "forwardedRef", "animation", "tag", "propsRest", "hostRef", "useRef", "composedRefs", "useComposedRefs", "stateRef", "current", "host", "state", "useThemeWithState", "result", "getSplitStyles", "Text", "staticConfig", "View", "theme", "name", "unmounted", "isAnimated", "noClass", "props", "viewProps", "Element", "transformedProps", "usePropsTransform", "_jsx", "AnimatedView", "AnimatedText", "onlyAnimateKeys", "transform", "opacity", "height", "width", "backgroundColor", "borderColor", "borderLeftColor", "borderRightColor", "borderTopColor", "borderBottomColor", "borderRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius", "borderLeftWidth", "borderRightWidth", "borderTopWidth", "borderBottomWidth", "color", "left", "right", "top", "bottom", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "createAnimations", "animations", "isWeb", "isReactNative", "usePresence", "ResetPresence", "useAnimatedNumber", "initial", "sharedValue", "useSharedValue", "React", "useMemo", "getInstance", "getValue", "value", "setValue", "next", "config", "type", "onFinish", "withSpring", "runOnJS", "undefined", "withTiming", "stop", "cancelAnimation", "useAnimatedNumberReaction", "onValue", "instance", "useAnimatedReaction", "prev", "useAnimatedNumberStyle", "val", "getStyle", "derivedValue", "useDerivedValue", "useAnimatedStyle", "useAnimations", "animationProps", "presence", "style", "componentState", "animationKey", "Array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V,eAAejF;QAC3C2F;QACAkB;QACA7B,OAAO;UAACU;UAAamB,KAAK7B;;MAC5B,CAAA,GAGK;QACLA,OAAO;UAACU;UAAamB,KAAK7B;;MAC5B;IACF;EACF;AACF;",
|
|
5
|
+
"names": ["createTamaguiAnimatedComponent", "defaultTag", "isText", "Component", "Animated", "createAnimatedComponent", "forwardRef", "propsIn", "ref", "hooks", "forwardedRef", "animation", "tag", "propsRest", "hostRef", "useRef", "composedRefs", "useComposedRefs", "stateRef", "current", "host", "_", "state", "useThemeWithState", "result", "getSplitStyles", "Text", "staticConfig", "View", "theme", "name", "unmounted", "isAnimated", "noClass", "props", "viewProps", "Element", "transformedProps", "usePropsTransform", "_jsx", "AnimatedView", "AnimatedText", "onlyAnimateKeys", "transform", "opacity", "height", "width", "backgroundColor", "borderColor", "borderLeftColor", "borderRightColor", "borderTopColor", "borderBottomColor", "borderRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius", "borderLeftWidth", "borderRightWidth", "borderTopWidth", "borderBottomWidth", "color", "left", "right", "top", "bottom", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "createAnimations", "animations", "isWeb", "isReactNative", "usePresence", "ResetPresence", "useAnimatedNumber", "initial", "sharedValue", "useSharedValue", "React", "useMemo", "getInstance", "getValue", "value", "setValue", "next", "config", "type", "onFinish", "withSpring", "runOnJS", "undefined", "withTiming", "stop", "cancelAnimation", "useAnimatedNumberReaction", "onValue", "instance", "useAnimatedReaction", "prev", "useAnimatedNumberStyle", "val", "getStyle", "derivedValue", "useDerivedValue", "useAnimatedStyle", "useAnimations", "animationProps", "presence", "style", "componentState", "animationKey", "Array", "isArray", "isHydrating", "disableAnimation", "presenceContext", "useContext", "PresenceContext", "dontAnimate", "motiProps", "animate", "animateOnly", "key", "startsWith", "includes", "styles", "isExiting", "Boolean", "usePresenceValue", "transition", "duration", "hasClonedTransition", "Object", "assign", "exit", "JSON", "stringify", "moti", "useMotify", "process", "env", "NODE_ENV", "console", "info"]
|
|
6
6
|
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
View
|
|
10
10
|
} from "@tamagui/web";
|
|
11
11
|
import { useMotify } from "moti/author";
|
|
12
|
-
import React, { forwardRef, useRef } from "react";
|
|
12
|
+
import React, { forwardRef, useMemo, useRef } from "react";
|
|
13
13
|
import Animated, {
|
|
14
14
|
cancelAnimation,
|
|
15
15
|
runOnJS,
|
|
@@ -30,7 +30,7 @@ function createTamaguiAnimatedComponent(defaultTag = "div") {
|
|
|
30
30
|
return hostRef.current;
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
|
-
const [
|
|
33
|
+
const [_, state] = useThemeWithState({}), props = getSplitStyles(
|
|
34
34
|
propsRest,
|
|
35
35
|
isText ? Text.staticConfig : View.staticConfig,
|
|
36
36
|
state?.theme,
|
|
@@ -145,35 +145,39 @@ function createAnimations(animations) {
|
|
|
145
145
|
return useAnimatedStyle(() => getStyle(derivedValue.value), [val, getStyle, derivedValue, instance]);
|
|
146
146
|
},
|
|
147
147
|
useAnimations: (animationProps) => {
|
|
148
|
-
const { props, presence, style, componentState } = animationProps, animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation, isHydrating = componentState.unmounted === !0, disableAnimation = isHydrating || !animationKey
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
const { props, presence, style, componentState } = animationProps, animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation, isHydrating = componentState.unmounted === !0, disableAnimation = isHydrating || !animationKey, presenceContext = React.useContext(PresenceContext), { dontAnimate, motiProps } = useMemo(() => {
|
|
149
|
+
let animate = {}, dontAnimate2 = {};
|
|
150
|
+
if (disableAnimation)
|
|
151
|
+
dontAnimate2 = style;
|
|
152
|
+
else {
|
|
153
|
+
const animateOnly = props.animateOnly;
|
|
154
|
+
for (const key in style) {
|
|
155
|
+
const value = style[key];
|
|
156
|
+
!onlyAnimateKeys[key] || value === "auto" || typeof value == "string" && value.startsWith("calc") || animateOnly && !animateOnly.includes(key) ? dontAnimate2[key] = value : animate[key] = value;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
componentState.unmounted === "should-enter" && (dontAnimate2 = style);
|
|
160
|
+
const styles = animate, isExiting = !!presence?.[1], usePresenceValue = presence || void 0;
|
|
161
|
+
let transition = isHydrating ? { type: "transition", duration: 0 } : animations[animationKey], hasClonedTransition = !1;
|
|
162
|
+
if (Array.isArray(props.animation)) {
|
|
163
|
+
const config = props.animation[1];
|
|
164
|
+
if (config && typeof config == "object")
|
|
165
|
+
for (const key in config) {
|
|
166
|
+
const val = config[key];
|
|
167
|
+
hasClonedTransition || (transition = Object.assign({}, transition), hasClonedTransition = !0), typeof val == "string" ? transition[key] = animations[val] : transition[key] = val;
|
|
168
|
+
}
|
|
157
169
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const val = config[key];
|
|
167
|
-
hasClonedTransition || (transition = Object.assign({}, transition), hasClonedTransition = !0), typeof val == "string" ? transition[key] = animations[val] : transition[key] = val;
|
|
170
|
+
return {
|
|
171
|
+
dontAnimate: dontAnimate2,
|
|
172
|
+
motiProps: {
|
|
173
|
+
animate: isExiting || componentState.unmounted === !0 ? {} : styles,
|
|
174
|
+
transition: componentState.unmounted ? { duration: 0 } : transition,
|
|
175
|
+
usePresenceValue,
|
|
176
|
+
presenceContext,
|
|
177
|
+
exit: isExiting ? styles : void 0
|
|
168
178
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
animate: isExiting || componentState.unmounted === !0 ? {} : styles,
|
|
172
|
-
transition: componentState.unmounted ? { duration: 0 } : transition,
|
|
173
|
-
usePresenceValue,
|
|
174
|
-
presenceContext,
|
|
175
|
-
exit: isExiting ? styles : void 0
|
|
176
|
-
}, moti = useMotify(motiProps);
|
|
179
|
+
};
|
|
180
|
+
}, [animationKey, componentState.unmounted, JSON.stringify(style), presenceContext]), moti = useMotify(motiProps);
|
|
177
181
|
return process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("useMotify(", JSON.stringify(motiProps, null, 2) + ")", {
|
|
178
182
|
"componentState.unmounted": componentState.unmounted,
|
|
179
183
|
motiProps,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/createAnimations.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,iBAAiB,eAAe,mBAAmB;AAC5D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,iBAAiB;AAE1B,OAAO,SAAS,YAAY,cAAc;
|
|
5
|
-
"names": []
|
|
4
|
+
"mappings": "AAAA,SAAS,iBAAiB,eAAe,mBAAmB;AAC5D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,iBAAiB;AAE1B,OAAO,SAAS,YAAY,SAAS,cAAc;AAGnD,OAAO;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA6CM;AAtCb,SAAS,+BAA+B,aAAa,OAAO;AAC1D,QAAM,SAAS,eAAe,QAExB,YAAY,SAAS;AAAA,IACzB,WAAW,CAAC,SAAc,QAAQ;AAChC,YAAM,EAAE,cAAc,WAAW,MAAM,YAAY,GAAG,UAAU,IAAI,SAC9D,UAAU,OAAO,GACjB,eAAe,gBAAgB,cAAc,KAAK,OAAO,GACzD,WAAW,OAAY;AAC7B,MAAK,SAAS,YACZ,SAAS,UAAU;AAAA,QACjB,IAAI,OAAO;AACT,iBAAO,QAAQ;AAAA,QACjB;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,SAAS,aAAa,eAAe,cAAc,KAAO,CAAC,IAAI;AAAA,YAC/D,YAAY,eAAe,YAAY,EAAE,UAAU,EAAE,IAAI;AAAA,YACzD;AAAA,YACA;AAAA,YACA,MAAM,YAAY,SAAS;AAAA,UAC7B;AAAA,QACF;AAAA,MACF,GAAG,CAAC,cAAc,eAAe,WAAW,KAAK,UAAU,KAAK,GAAG,eAAe,CAAC,GAE7E,OAAO,UAAU,SAAS;AAEhC,aACE,QAAQ,IAAI,aAAa,iBACzB,MAAM,SACN,MAAM,UAAa,aAEnB,QAAQ,KAAK,cAAc,KAAK,UAAU,WAAW,MAAM,CAAC,IAAI,KAAK;AAAA,QACnE,4BAA4B,eAAe;AAAA,QAC3C;AAAA,QACA;AAAA,QACA,OAAO,CAAC,aAAa,KAAK,KAAK;AAAA,MACjC,CAAC,GAGI;AAAA,QACL,OAAO,CAAC,aAAa,KAAK,KAAK;AAAA,MACjC;AAAA,IACF;AAAA,EACF;AACF;",
|
|
5
|
+
"names": ["dontAnimate"]
|
|
6
6
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PresenceContext, ResetPresence, usePresence } from "@tamagui/use-presence";
|
|
2
2
|
import { getSplitStyles, hooks, isWeb, Text, useComposedRefs, useThemeWithState, View } from "@tamagui/web";
|
|
3
3
|
import { useMotify } from "moti/author";
|
|
4
|
-
import React, { forwardRef, useRef } from "react";
|
|
4
|
+
import React, { forwardRef, useMemo, useRef } from "react";
|
|
5
5
|
import Animated, { cancelAnimation, runOnJS, useAnimatedReaction, useAnimatedStyle, useDerivedValue, useSharedValue, withSpring, withTiming } from "react-native-reanimated";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
function createTamaguiAnimatedComponent(defaultTag = "div") {
|
|
@@ -21,9 +21,7 @@ function createTamaguiAnimatedComponent(defaultTag = "div") {
|
|
|
21
21
|
return hostRef.current;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
const [{
|
|
25
|
-
state
|
|
26
|
-
}] = useThemeWithState({}),
|
|
24
|
+
const [_, state] = useThemeWithState({}),
|
|
27
25
|
props = getSplitStyles(propsRest, isText ? Text.staticConfig : View.staticConfig, state?.theme, state?.name, {
|
|
28
26
|
unmounted: !1
|
|
29
27
|
}, {
|
|
@@ -143,42 +141,50 @@ function createAnimations(animations) {
|
|
|
143
141
|
} = animationProps,
|
|
144
142
|
animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation,
|
|
145
143
|
isHydrating = componentState.unmounted === !0,
|
|
146
|
-
disableAnimation = isHydrating || !animationKey
|
|
147
|
-
let animate = {},
|
|
148
|
-
dontAnimate = {};
|
|
149
|
-
if (disableAnimation) dontAnimate = style;else {
|
|
150
|
-
const animateOnly = props.animateOnly;
|
|
151
|
-
for (const key in style) {
|
|
152
|
-
const value = style[key];
|
|
153
|
-
!onlyAnimateKeys[key] || value === "auto" || typeof value == "string" && value.startsWith("calc") || animateOnly && !animateOnly.includes(key) ? dontAnimate[key] = value : animate[key] = value;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
componentState.unmounted === "should-enter" && (dontAnimate = style);
|
|
157
|
-
const styles = animate,
|
|
158
|
-
isExiting = !!presence?.[1],
|
|
144
|
+
disableAnimation = isHydrating || !animationKey,
|
|
159
145
|
presenceContext = React.useContext(PresenceContext),
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
146
|
+
{
|
|
147
|
+
dontAnimate,
|
|
148
|
+
motiProps
|
|
149
|
+
} = useMemo(() => {
|
|
150
|
+
let animate = {},
|
|
151
|
+
dontAnimate2 = {};
|
|
152
|
+
if (disableAnimation) dontAnimate2 = style;else {
|
|
153
|
+
const animateOnly = props.animateOnly;
|
|
154
|
+
for (const key in style) {
|
|
155
|
+
const value = style[key];
|
|
156
|
+
!onlyAnimateKeys[key] || value === "auto" || typeof value == "string" && value.startsWith("calc") || animateOnly && !animateOnly.includes(key) ? dontAnimate2[key] = value : animate[key] = value;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
componentState.unmounted === "should-enter" && (dontAnimate2 = style);
|
|
160
|
+
const styles = animate,
|
|
161
|
+
isExiting = !!presence?.[1],
|
|
162
|
+
usePresenceValue = presence || void 0;
|
|
163
|
+
let transition = isHydrating ? {
|
|
164
|
+
type: "transition",
|
|
165
|
+
duration: 0
|
|
166
|
+
} : animations[animationKey],
|
|
167
|
+
hasClonedTransition = !1;
|
|
168
|
+
if (Array.isArray(props.animation)) {
|
|
169
|
+
const config = props.animation[1];
|
|
170
|
+
if (config && typeof config == "object") for (const key in config) {
|
|
171
|
+
const val = config[key];
|
|
172
|
+
hasClonedTransition || (transition = Object.assign({}, transition), hasClonedTransition = !0), typeof val == "string" ? transition[key] = animations[val] : transition[key] = val;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
dontAnimate: dontAnimate2,
|
|
177
|
+
motiProps: {
|
|
178
|
+
animate: isExiting || componentState.unmounted === !0 ? {} : styles,
|
|
179
|
+
transition: componentState.unmounted ? {
|
|
180
|
+
duration: 0
|
|
181
|
+
} : transition,
|
|
182
|
+
usePresenceValue,
|
|
183
|
+
presenceContext,
|
|
184
|
+
exit: isExiting ? styles : void 0
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}, [animationKey, componentState.unmounted, JSON.stringify(style), presenceContext]),
|
|
182
188
|
moti = useMotify(motiProps);
|
|
183
189
|
return process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("useMotify(", JSON.stringify(motiProps, null, 2) + ")", {
|
|
184
190
|
"componentState.unmounted": componentState.unmounted,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PresenceContext","ResetPresence","usePresence","getSplitStyles","hooks","isWeb","Text","useComposedRefs","useThemeWithState","View","useMotify","React","forwardRef","useRef","Animated","cancelAnimation","runOnJS","useAnimatedReaction","useAnimatedStyle","useDerivedValue","useSharedValue","withSpring","withTiming","jsx","createTamaguiAnimatedComponent","defaultTag","isText","Component","createAnimatedComponent","propsIn","ref","forwardedRef","animation","tag","propsRest","hostRef","composedRefs","stateRef","current","host","state","props","staticConfig","theme","name","unmounted","isAnimated","noClass","viewProps","Element","transformedProps","usePropsTransform","acceptTagProp","AnimatedView","AnimatedText","onlyAnimateKeys","transform","opacity","height","width","backgroundColor","borderColor","borderLeftColor","borderRightColor","borderTopColor","borderBottomColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth","color","left","right","top","bottom","fontSize","fontWeight","lineHeight","letterSpacing","createAnimations","animations","isReactNative","useAnimatedNumber","initial","sharedValue","
|
|
1
|
+
{"version":3,"names":["PresenceContext","ResetPresence","usePresence","getSplitStyles","hooks","isWeb","Text","useComposedRefs","useThemeWithState","View","useMotify","React","forwardRef","useMemo","useRef","Animated","cancelAnimation","runOnJS","useAnimatedReaction","useAnimatedStyle","useDerivedValue","useSharedValue","withSpring","withTiming","jsx","createTamaguiAnimatedComponent","defaultTag","isText","Component","createAnimatedComponent","propsIn","ref","forwardedRef","animation","tag","propsRest","hostRef","composedRefs","stateRef","current","host","_","state","props","staticConfig","theme","name","unmounted","isAnimated","noClass","viewProps","Element","transformedProps","usePropsTransform","acceptTagProp","AnimatedView","AnimatedText","onlyAnimateKeys","transform","opacity","height","width","backgroundColor","borderColor","borderLeftColor","borderRightColor","borderTopColor","borderBottomColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth","color","left","right","top","bottom","fontSize","fontWeight","lineHeight","letterSpacing","createAnimations","animations","isReactNative","useAnimatedNumber","initial","sharedValue","getInstance","getValue","value","setValue","next","config","type","onFinish","stop","useAnimatedNumberReaction","onValue","instance","prev","useAnimatedNumberStyle","val","getStyle","derivedValue","useAnimations","animationProps","presence","style","componentState","animationKey","Array","isArray","isHydrating","disableAnimation","presenceContext","useContext","dontAnimate","motiProps","animate","dontAnimate2","animateOnly","key","startsWith","includes","styles","isExiting","usePresenceValue","transition","duration","hasClonedTransition","Object","assign","exit","JSON","stringify","moti","process","env","NODE_ENV","debug","console","info"],"sources":["../../src/createAnimations.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,eAAA,EAAiBC,aAAA,EAAeC,WAAA,QAAmB;AAC5D,SACEC,cAAA,EACAC,KAAA,EACAC,KAAA,EACAC,IAAA,EACAC,eAAA,EACAC,iBAAA,EACAC,IAAA,QAGK;AAEP,SAASC,SAAA,QAAiB;AAE1B,OAAOC,KAAA,IAASC,UAAA,EAAYC,OAAA,EAASC,MAAA,QAAc;AAGnD,OAAOC,QAAA,IACLC,eAAA,EACAC,OAAA,EACAC,mBAAA,EACAC,gBAAA,EACAC,eAAA,EACAC,cAAA,EACAC,UAAA,EACAC,UAAA,QACK;AA6CM,SAAAC,GAAA;AAtCb,SAASC,+BAA+BC,UAAA,GAAa,OAAO;EAC1D,MAAMC,MAAA,GAASD,UAAA,KAAe;IAExBE,SAAA,GAAYb,QAAA,CAASc,uBAAA,CACzBjB,UAAA,CAAW,CAACkB,OAAA,EAAcC,GAAA,KAAQ;MAChC,MAAM;UAAEC,YAAA;UAAcC,SAAA;UAAWC,GAAA,GAAMR,UAAA;UAAY,GAAGS;QAAU,IAAIL,OAAA;QAC9DM,OAAA,GAAUtB,MAAA,CAAO;QACjBuB,YAAA,GAAe9B,eAAA,CAAgByB,YAAA,EAAcD,GAAA,EAAKK,OAAO;QACzDE,QAAA,GAAWxB,MAAA,CAAY;MACxBwB,QAAA,CA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AA,CAAWN,GAAG,IAAIpB,GAAA;YAEtB;UAEJ;UAEA,OAAO;YACLe,WAAA,EAAAG,YAAA;YACAF,SAAA,EAAW;cACTC,OAAA,EAASO,SAAA,IAAajB,cAAA,CAAelE,SAAA,KAAc,KAAO,CAAC,IAAIkF,MAAA;cAC/DG,UAAA,EAAYnB,cAAA,CAAelE,SAAA,GAAY;gBAAEsF,QAAA,EAAU;cAAE,IAAID,UAAA;cACzDD,gBAAA;cACAZ,eAAA;cACAkB,IAAA,EAAMP,SAAA,GAAYD,MAAA,GAAS;YAC7B;UACF;QACF,GAAG,CAACf,YAAA,EAAcD,cAAA,CAAelE,SAAA,EAAW2F,IAAA,CAAKC,SAAA,CAAU3B,KAAK,GAAGO,eAAe,CAAC;QAE7EqB,IAAA,GAAOlI,SAAA,CAAUgH,SAAS;MAEhC,OACEmB,OAAA,CAAQC,GAAA,CAAIC,QAAA,KAAa,iBACzBpG,KAAA,CAAMqG,KAAA,IACNrG,KAAA,CAAMqG,KAAA,KAAa,aAEnBC,OAAA,CAAQC,IAAA,CAAK,cAAcR,IAAA,CAAKC,SAAA,CAAUjB,SAAA,EAAW,MAAM,CAAC,IAAI,KAAK;QACnE,4BAA4BT,cAAA,CAAelE,SAAA;QAC3C2E,SAAA;QACAkB,IAAA;QACA5B,KAAA,EAAO,CAACS,WAAA,EAAamB,IAAA,CAAK5B,KAAK;MACjC,CAAC,GAGI;QACLA,KAAA,EAAO,CAACS,WAAA,EAAamB,IAAA,CAAK5B,KAAK;MACjC;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { PresenceContext, ResetPresence, usePresence } from "@tamagui/use-presence";
|
|
3
3
|
import { getSplitStyles, hooks, isWeb, Text, useComposedRefs, useThemeWithState, View } from "@tamagui/web";
|
|
4
4
|
import { useMotify } from "moti/author";
|
|
5
|
-
import React, { forwardRef, useRef } from "react";
|
|
5
|
+
import React, { forwardRef, useMemo, useRef } from "react";
|
|
6
6
|
import Animated, { cancelAnimation, runOnJS, useAnimatedReaction, useAnimatedStyle, useDerivedValue, useSharedValue, withSpring, withTiming } from "react-native-reanimated";
|
|
7
7
|
function createTamaguiAnimatedComponent() {
|
|
8
8
|
var defaultTag = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "div", isText = defaultTag === "span", Component = Animated.createAnimatedComponent(/* @__PURE__ */ forwardRef(function(propsIn, ref) {
|
|
@@ -12,7 +12,7 @@ function createTamaguiAnimatedComponent() {
|
|
|
12
12
|
return hostRef.current;
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
-
var [
|
|
15
|
+
var [_, state] = useThemeWithState({}), result = getSplitStyles(propsRest, isText ? Text.staticConfig : View.staticConfig, state?.theme, state?.name, {
|
|
16
16
|
unmounted: !1
|
|
17
17
|
}, {
|
|
18
18
|
isAnimated: !1,
|
|
@@ -143,38 +143,48 @@ function createAnimations(animations) {
|
|
|
143
143
|
);
|
|
144
144
|
},
|
|
145
145
|
useAnimations: function(animationProps) {
|
|
146
|
-
var { props, presence, style, componentState } = animationProps, animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation, isHydrating = componentState.unmounted === !0, disableAnimation = isHydrating || !animationKey,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
var
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
componentState.unmounted === "should-enter" && (dontAnimate = style);
|
|
157
|
-
var styles = animate, isExiting = !!presence?.[1], presenceContext = React.useContext(PresenceContext), usePresenceValue = presence || void 0, transition = isHydrating ? {
|
|
158
|
-
type: "transition",
|
|
159
|
-
duration: 0
|
|
160
|
-
} : animations[animationKey], hasClonedTransition = !1;
|
|
161
|
-
if (Array.isArray(props.animation)) {
|
|
162
|
-
var config = props.animation[1];
|
|
163
|
-
if (config && typeof config == "object")
|
|
164
|
-
for (var key1 in config) {
|
|
165
|
-
var val = config[key1];
|
|
166
|
-
hasClonedTransition || (transition = Object.assign({}, transition), hasClonedTransition = !0), typeof val == "string" ? transition[key1] = animations[val] : transition[key1] = val;
|
|
146
|
+
var { props, presence, style, componentState } = animationProps, animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation, isHydrating = componentState.unmounted === !0, disableAnimation = isHydrating || !animationKey, presenceContext = React.useContext(PresenceContext), { dontAnimate, motiProps } = useMemo(function() {
|
|
147
|
+
var animate = {}, dontAnimate2 = {};
|
|
148
|
+
if (disableAnimation)
|
|
149
|
+
dontAnimate2 = style;
|
|
150
|
+
else {
|
|
151
|
+
var animateOnly = props.animateOnly;
|
|
152
|
+
for (var key in style) {
|
|
153
|
+
var value = style[key];
|
|
154
|
+
!onlyAnimateKeys[key] || value === "auto" || typeof value == "string" && value.startsWith("calc") || animateOnly && !animateOnly.includes(key) ? dontAnimate2[key] = value : animate[key] = value;
|
|
167
155
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
animate
|
|
171
|
-
|
|
156
|
+
}
|
|
157
|
+
componentState.unmounted === "should-enter" && (dontAnimate2 = style);
|
|
158
|
+
var styles = animate, isExiting = !!presence?.[1], usePresenceValue = presence || void 0, transition = isHydrating ? {
|
|
159
|
+
type: "transition",
|
|
172
160
|
duration: 0
|
|
173
|
-
} :
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
161
|
+
} : animations[animationKey], hasClonedTransition = !1;
|
|
162
|
+
if (Array.isArray(props.animation)) {
|
|
163
|
+
var config = props.animation[1];
|
|
164
|
+
if (config && typeof config == "object")
|
|
165
|
+
for (var key1 in config) {
|
|
166
|
+
var val = config[key1];
|
|
167
|
+
hasClonedTransition || (transition = Object.assign({}, transition), hasClonedTransition = !0), typeof val == "string" ? transition[key1] = animations[val] : transition[key1] = val;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
dontAnimate: dontAnimate2,
|
|
172
|
+
motiProps: {
|
|
173
|
+
animate: isExiting || componentState.unmounted === !0 ? {} : styles,
|
|
174
|
+
transition: componentState.unmounted ? {
|
|
175
|
+
duration: 0
|
|
176
|
+
} : transition,
|
|
177
|
+
usePresenceValue,
|
|
178
|
+
presenceContext,
|
|
179
|
+
exit: isExiting ? styles : void 0
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}, [
|
|
183
|
+
animationKey,
|
|
184
|
+
componentState.unmounted,
|
|
185
|
+
JSON.stringify(style),
|
|
186
|
+
presenceContext
|
|
187
|
+
]), moti = useMotify(motiProps);
|
|
178
188
|
return process.env.NODE_ENV === "development" && props.debug && props.debug !== "profile" && console.info("useMotify(", JSON.stringify(motiProps, null, 2) + ")", {
|
|
179
189
|
"componentState.unmounted": componentState.unmounted,
|
|
180
190
|
motiProps,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Users/n8/tamagui/code/core/animations-moti/src/createAnimations.tsx"],
|
|
4
|
-
"mappings": ";AAAA,SAASA,iBAAiBC,eAAeC,mBAAmB;AAC5D,SACEC,gBACAC,OACAC,OACAC,MACAC,iBACAC,mBACAC,YAGK;AAEP,SAASC,iBAAiB;AAE1B,OAAOC,SAASC,YAAYC,cAAc;
|
|
5
|
-
"names": ["PresenceContext", "ResetPresence", "usePresence", "getSplitStyles", "hooks", "isWeb", "Text", "useComposedRefs", "useThemeWithState", "View", "useMotify", "React", "forwardRef", "useRef", "Animated", "cancelAnimation", "runOnJS", "useAnimatedReaction", "useAnimatedStyle", "useDerivedValue", "useSharedValue", "withSpring", "withTiming", "createTamaguiAnimatedComponent", "defaultTag", "isText", "Component", "createAnimatedComponent", "propsIn", "ref", "forwardedRef", "animation", "tag", "propsRest", "hostRef", "composedRefs", "stateRef", "current", "host", "state", "result", "staticConfig", "theme", "name", "unmounted", "isAnimated", "noClass", "props", "viewProps", "Element", "transformedProps", "usePropsTransform", "AnimatedView", "AnimatedText", "onlyAnimateKeys", "transform", "opacity", "height", "width", "backgroundColor", "borderColor", "borderLeftColor", "borderRightColor", "borderTopColor", "borderBottomColor", "borderRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius", "borderLeftWidth", "borderRightWidth", "borderTopWidth", "borderBottomWidth", "color", "left", "right", "top", "bottom", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "createAnimations", "animations", "isReactNative", "useAnimatedNumber", "initial", "sharedValue", "
|
|
4
|
+
"mappings": ";AAAA,SAASA,iBAAiBC,eAAeC,mBAAmB;AAC5D,SACEC,gBACAC,OACAC,OACAC,MACAC,iBACAC,mBACAC,YAGK;AAEP,SAASC,iBAAiB;AAE1B,OAAOC,SAASC,YAAYC,SAASC,cAAc;AAGnD,OAAOC,YACLC,iBACAC,SACAC,qBACAC,kBACAC,iBACAC,gBACAC,YACAC,kBACK;AAOP,SAASC,iCAAAA;MAA+BC,aAAAA,UAAAA,SAAAA,KAAAA,UAAAA,CAAAA,MAAAA,SAAAA,UAAAA,CAAAA,IAAa,OAC7CC,SAASD,eAAe,QAExBE,YAAYZ,SAASa,wBACzBhB,2BAAW,SAACiB,SAAcC,KAAAA;QAgCC1B,0BA/BnB,EAAE2B,cAAcC,WAAWC,MAAMR,YAAY,GAAGS,UAAAA,IAAcL,SAC9DM,UAAUrB,OAAAA,GACVsB,eAAe7B,gBAAgBwB,cAAcD,KAAKK,OAAAA,GAClDE,WAAWvB,OAAAA;AACjB,IAAKuB,SAASC,YACZD,SAASC,UAAU;MACjB,IAAIC,OAAO;AACT,eAAOJ,QAAQG;MACjB;IACF;AAGF,QAAM,CAACE,GAAGC,KAAAA,IAASjC,kBAAkB,CAAC,CAAA,GAGhCkC,SAASvC,eACb+B,WACAR,SAASpB,KAAKqC,eAAelC,KAAKkC,cAClCF,OAAOG,OACPH,OAAOI,MACP;MACEC,WAAW;IACb,GACA;MACEC,YAAY;MACZC,SAAS;IACX,CAAA,GAGIC,QAAQP,OAA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,SAAS7B;UAC7B;QACF;MACF,GAAG;QAACe;QAAcD,eAAenE;QAAW4F,KAAKC,UAAU3B,KAAAA;QAAQO;OAAgB,GAE7EqB,OAAOlI,UAAUgH,SAAAA;AAEvB,aACEmB,QAAQC,IAAIC,aAAa,iBACzB9F,MAAM,SACNA,MAAM,UAAa,aAEnB+F,QAAQC,KAAK,cAAcP,KAAKC,UAAUjB,WAAW,MAAM,CAAA,IAAK,KAAK;QACnE,4BAA4BT,eAAenE;QAC3C4E;QACAkB;QACA5B,OAAO;UAACS;UAAamB,KAAK5B;;MAC5B,CAAA,GAGK;QACLA,OAAO;UAACS;UAAamB,KAAK5B;;MAC5B;IACF;EACF;AACF;",
|
|
5
|
+
"names": ["PresenceContext", "ResetPresence", "usePresence", "getSplitStyles", "hooks", "isWeb", "Text", "useComposedRefs", "useThemeWithState", "View", "useMotify", "React", "forwardRef", "useMemo", "useRef", "Animated", "cancelAnimation", "runOnJS", "useAnimatedReaction", "useAnimatedStyle", "useDerivedValue", "useSharedValue", "withSpring", "withTiming", "createTamaguiAnimatedComponent", "defaultTag", "isText", "Component", "createAnimatedComponent", "propsIn", "ref", "forwardedRef", "animation", "tag", "propsRest", "hostRef", "composedRefs", "stateRef", "current", "host", "_", "state", "result", "staticConfig", "theme", "name", "unmounted", "isAnimated", "noClass", "props", "viewProps", "Element", "transformedProps", "usePropsTransform", "AnimatedView", "AnimatedText", "onlyAnimateKeys", "transform", "opacity", "height", "width", "backgroundColor", "borderColor", "borderLeftColor", "borderRightColor", "borderTopColor", "borderBottomColor", "borderRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius", "borderLeftWidth", "borderRightWidth", "borderTopWidth", "borderBottomWidth", "color", "left", "right", "top", "bottom", "fontSize", "fontWeight", "lineHeight", "letterSpacing", "createAnimations", "animations", "isReactNative", "useAnimatedNumber", "initial", "sharedValue", "getInstance", "getValue", "value", "setValue", "next", "config", "type", "onFinish", "undefined", "stop", "useAnimatedNumberReaction", "onValue", "instance", "prev", "useAnimatedNumberStyle", "val", "getStyle", "derivedValue", "useAnimations", "animationProps", "presence", "style", "componentState", "animationKey", "Array", "isArray", "isHydrating", "disableAnimation", "presenceContext", "useContext", "dontAnimate", "motiProps", "animate", "animateOnly", "key", "startsWith", "includes", "styles", "isExiting", "Boolean", "usePresenceValue", "transition", "duration", "hasClonedTransition", "Object", "assign", "exit", "JSON", "stringify", "moti", "process", "env", "NODE_ENV", "console", "info"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/animations-moti",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.124.0",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tamagui/use-presence": "1.
|
|
33
|
-
"@tamagui/web": "1.
|
|
32
|
+
"@tamagui/use-presence": "1.124.0",
|
|
33
|
+
"@tamagui/web": "1.124.0",
|
|
34
34
|
"moti": "^0.29.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@tamagui/build": "1.
|
|
37
|
+
"@tamagui/build": "1.124.0",
|
|
38
38
|
"react": "*",
|
|
39
39
|
"react-native-reanimated": "~3.16.1"
|
|
40
40
|
},
|
package/src/createAnimations.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import type { TransitionConfig } from 'moti'
|
|
14
14
|
import { useMotify } from 'moti/author'
|
|
15
15
|
import type { CSSProperties } from 'react'
|
|
16
|
-
import React, { forwardRef, useRef } from 'react'
|
|
16
|
+
import React, { forwardRef, useMemo, useRef } from 'react'
|
|
17
17
|
import type { TextStyle } from 'react-native'
|
|
18
18
|
import type { SharedValue } from 'react-native-reanimated'
|
|
19
19
|
import Animated, {
|
|
@@ -49,7 +49,7 @@ function createTamaguiAnimatedComponent(defaultTag = 'div') {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const [
|
|
52
|
+
const [_, state] = useThemeWithState({})
|
|
53
53
|
|
|
54
54
|
// get styles but only inline style
|
|
55
55
|
const result = getSplitStyles(
|
|
@@ -227,78 +227,85 @@ export function createAnimations<A extends Record<string, TransitionConfig>>(
|
|
|
227
227
|
|
|
228
228
|
const isHydrating = componentState.unmounted === true
|
|
229
229
|
const disableAnimation = isHydrating || !animationKey
|
|
230
|
+
const presenceContext = React.useContext(PresenceContext)
|
|
230
231
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
dontAnimate =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
value
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
232
|
+
// this memo is very important for performance, there's a big cost to
|
|
233
|
+
// updating these values every render
|
|
234
|
+
const { dontAnimate, motiProps } = useMemo(() => {
|
|
235
|
+
let animate = {}
|
|
236
|
+
let dontAnimate = {}
|
|
237
|
+
|
|
238
|
+
if (disableAnimation) {
|
|
239
|
+
dontAnimate = style
|
|
240
|
+
} else {
|
|
241
|
+
const animateOnly = props.animateOnly as string[]
|
|
242
|
+
for (const key in style) {
|
|
243
|
+
const value = style[key]
|
|
244
|
+
if (
|
|
245
|
+
!onlyAnimateKeys[key] ||
|
|
246
|
+
value === 'auto' ||
|
|
247
|
+
(typeof value === 'string' && value.startsWith('calc')) ||
|
|
248
|
+
(animateOnly && !animateOnly.includes(key))
|
|
249
|
+
) {
|
|
250
|
+
dontAnimate[key] = value
|
|
251
|
+
} else {
|
|
252
|
+
animate[key] = value
|
|
253
|
+
}
|
|
249
254
|
}
|
|
250
255
|
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// if we don't do this moti seems to flicker a frame before applying animation
|
|
254
|
-
if (componentState.unmounted === 'should-enter') {
|
|
255
|
-
dontAnimate = style
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
const styles = animate
|
|
259
|
-
const isExiting = Boolean(presence?.[1])
|
|
260
|
-
const presenceContext = React.useContext(PresenceContext)
|
|
261
|
-
const usePresenceValue = (presence || undefined) as any
|
|
262
|
-
|
|
263
|
-
type UseMotiProps = Parameters<typeof useMotify>[0]
|
|
264
256
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
let hasClonedTransition = false
|
|
271
|
-
|
|
272
|
-
if (Array.isArray(props.animation)) {
|
|
273
|
-
const config = props.animation[1]
|
|
274
|
-
if (config && typeof config === 'object') {
|
|
275
|
-
for (const key in config) {
|
|
276
|
-
const val = config[key]
|
|
277
|
-
|
|
278
|
-
// performance - this seems to have (strangely) huge performance effect in uniswap
|
|
279
|
-
// so instead of cloning up front, we clone only when we absolutely have to
|
|
280
|
-
if (!hasClonedTransition) {
|
|
281
|
-
transition = Object.assign({}, transition)
|
|
282
|
-
hasClonedTransition = true
|
|
283
|
-
}
|
|
257
|
+
// if we don't do this moti seems to flicker a frame before applying animation
|
|
258
|
+
if (componentState.unmounted === 'should-enter') {
|
|
259
|
+
dontAnimate = style
|
|
260
|
+
}
|
|
284
261
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
262
|
+
const styles = animate
|
|
263
|
+
const isExiting = Boolean(presence?.[1])
|
|
264
|
+
const usePresenceValue = (presence || undefined) as any
|
|
265
|
+
|
|
266
|
+
type UseMotiProps = Parameters<typeof useMotify>[0]
|
|
267
|
+
|
|
268
|
+
// TODO moti is giving us type troubles, but this should work
|
|
269
|
+
let transition = isHydrating
|
|
270
|
+
? { type: 'transition', duration: 0 }
|
|
271
|
+
: (animations[animationKey as keyof typeof animations] as any)
|
|
272
|
+
|
|
273
|
+
let hasClonedTransition = false
|
|
274
|
+
|
|
275
|
+
if (Array.isArray(props.animation)) {
|
|
276
|
+
const config = props.animation[1]
|
|
277
|
+
if (config && typeof config === 'object') {
|
|
278
|
+
for (const key in config) {
|
|
279
|
+
const val = config[key]
|
|
280
|
+
|
|
281
|
+
// performance - this seems to have (strangely) huge performance effect in uniswap
|
|
282
|
+
// so instead of cloning up front, we clone only when we absolutely have to
|
|
283
|
+
if (!hasClonedTransition) {
|
|
284
|
+
transition = Object.assign({}, transition)
|
|
285
|
+
hasClonedTransition = true
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// referencing a pre-defined config
|
|
289
|
+
if (typeof val === 'string') {
|
|
290
|
+
transition[key] = animations[val]
|
|
291
|
+
} else {
|
|
292
|
+
transition[key] = val
|
|
293
|
+
}
|
|
290
294
|
}
|
|
291
295
|
}
|
|
292
296
|
}
|
|
293
|
-
}
|
|
294
297
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
298
|
+
return {
|
|
299
|
+
dontAnimate,
|
|
300
|
+
motiProps: {
|
|
301
|
+
animate: isExiting || componentState.unmounted === true ? {} : styles,
|
|
302
|
+
transition: componentState.unmounted ? { duration: 0 } : transition,
|
|
303
|
+
usePresenceValue,
|
|
304
|
+
presenceContext,
|
|
305
|
+
exit: isExiting ? styles : undefined,
|
|
306
|
+
} satisfies UseMotiProps,
|
|
307
|
+
}
|
|
308
|
+
}, [animationKey, componentState.unmounted, JSON.stringify(style), presenceContext])
|
|
302
309
|
|
|
303
310
|
const moti = useMotify(motiProps)
|
|
304
311
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"src/createAnimations.tsx"
|
|
8
8
|
],
|
|
9
9
|
"sourcesContent": [
|
|
10
|
-
"import { PresenceContext, ResetPresence, usePresence } from '@tamagui/use-presence'\nimport {\n getSplitStyles,\n hooks,\n isWeb,\n Text,\n useComposedRefs,\n useThemeWithState,\n View,\n type AnimationDriver,\n type UniversalAnimatedNumber,\n} from '@tamagui/web'\nimport type { TransitionConfig } from 'moti'\nimport { useMotify } from 'moti/author'\nimport type { CSSProperties } from 'react'\nimport React, { forwardRef, useRef } from 'react'\nimport type { TextStyle } from 'react-native'\nimport type { SharedValue } from 'react-native-reanimated'\nimport Animated, {\n cancelAnimation,\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withSpring,\n withTiming,\n} from 'react-native-reanimated'\n\ntype ReanimatedAnimatedNumber = SharedValue<number>\n\n// this is our own custom reanimated animated component so we can allow data- attributes, className etc\n// this should ultimately be merged with react-native-web-lite\n\nfunction createTamaguiAnimatedComponent(defaultTag = 'div') {\n const isText = defaultTag === 'span'\n\n const Component = Animated.createAnimatedComponent(\n forwardRef((propsIn: any, ref) => {\n const { forwardedRef, animation, tag = defaultTag, ...propsRest } = propsIn\n const hostRef = useRef()\n const composedRefs = useComposedRefs(forwardedRef, ref, hostRef)\n const stateRef = useRef<any>()\n if (!stateRef.current) {\n stateRef.current = {\n get host() {\n return hostRef.current\n },\n }\n }\n\n const [{ state }] = useThemeWithState({})\n\n // get styles but only inline style\n const result = getSplitStyles(\n propsRest,\n isText ? Text.staticConfig : View.staticConfig,\n state?.theme!,\n state?.name!,\n {\n unmounted: false,\n } as any,\n {\n isAnimated: false,\n noClass: true,\n }\n )\n\n const props = result.viewProps\n const Element = tag\n const transformedProps = hooks.usePropsTransform?.(tag, props, stateRef, false)\n\n return <Element {...transformedProps} ref={composedRefs} />\n })\n )\n Component['acceptTagProp'] = true\n return Component\n}\n\nconst AnimatedView = createTamaguiAnimatedComponent('div')\nconst AnimatedText = createTamaguiAnimatedComponent('span')\n\n// const AnimatedView = styled(View, {\n// disableClassName: true,\n// })\n\n// const AnimatedText = styled(Text, {\n// disableClassName: true,\n// })\n\nconst onlyAnimateKeys: { [key in keyof TextStyle | keyof CSSProperties]?: boolean } = {\n transform: true,\n opacity: true,\n height: true,\n width: true,\n backgroundColor: true,\n borderColor: true,\n borderLeftColor: true,\n borderRightColor: true,\n borderTopColor: true,\n borderBottomColor: true,\n borderRadius: true,\n borderTopLeftRadius: true,\n borderTopRightRadius: true,\n borderBottomLeftRadius: true,\n borderBottomRightRadius: true,\n borderLeftWidth: true,\n borderRightWidth: true,\n borderTopWidth: true,\n borderBottomWidth: true,\n color: true,\n left: true,\n right: true,\n top: true,\n bottom: true,\n fontSize: true,\n fontWeight: true,\n lineHeight: true,\n letterSpacing: true,\n}\n\nexport function createAnimations<A extends Record<string, TransitionConfig>>(\n animations: A\n): AnimationDriver<A> {\n return {\n View: isWeb ? AnimatedView : Animated.View,\n Text: isWeb ? AnimatedText : Animated.Text,\n // View: Animated.View,\n // Text: Animated.Text,\n isReactNative: true,\n animations,\n usePresence,\n ResetPresence,\n\n useAnimatedNumber(initial): UniversalAnimatedNumber<ReanimatedAnimatedNumber> {\n const sharedValue = useSharedValue(initial)\n\n return React.useMemo(\n () => ({\n getInstance() {\n 'worklet'\n return sharedValue\n },\n getValue() {\n 'worklet'\n return sharedValue.value\n },\n setValue(next, config = { type: 'spring' }, onFinish) {\n 'worklet'\n if (config.type === 'direct') {\n sharedValue.value = next\n onFinish?.()\n } else if (config.type === 'spring') {\n sharedValue.value = withSpring(\n next,\n config,\n onFinish\n ? () => {\n 'worklet'\n runOnJS(onFinish)()\n }\n : undefined\n )\n } else {\n sharedValue.value = withTiming(\n next,\n config,\n onFinish\n ? () => {\n 'worklet'\n runOnJS(onFinish)()\n }\n : undefined\n )\n }\n },\n stop() {\n 'worklet'\n cancelAnimation(sharedValue)\n },\n }),\n [sharedValue]\n )\n },\n\n useAnimatedNumberReaction({ value }, onValue) {\n const instance = value.getInstance()\n return useAnimatedReaction(\n () => {\n return instance.value\n },\n (next, prev) => {\n if (prev !== next) {\n // @nate what is the point of this hook? is this necessary?\n // without runOnJS, onValue would need to be a worklet\n runOnJS(onValue)(next)\n }\n },\n // dependency array is very important here\n [onValue, instance]\n )\n },\n\n /**\n * `getStyle` must be a worklet\n */\n useAnimatedNumberStyle(val, getStyle) {\n const instance = val.getInstance()\n\n // this seems wrong but it works\n const derivedValue = useDerivedValue(() => {\n return instance.value\n // dependency array is very important here\n }, [instance, getStyle])\n\n return useAnimatedStyle(() => {\n return getStyle(derivedValue.value)\n // dependency array is very important here\n }, [val, getStyle, derivedValue, instance])\n },\n\n useAnimations: (animationProps) => {\n const { props, presence, style, componentState } = animationProps\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\n let animate = {}\n let dontAnimate = {}\n\n if (disableAnimation) {\n dontAnimate = style\n } else {\n const animateOnly = props.animateOnly as string[]\n for (const key in style) {\n const value = style[key]\n if (\n !onlyAnimateKeys[key] ||\n value === 'auto' ||\n (typeof value === 'string' && value.startsWith('calc')) ||\n (animateOnly && !animateOnly.includes(key))\n ) {\n dontAnimate[key] = value\n } else {\n animate[key] = value\n }\n }\n }\n\n // if we don't do this moti seems to flicker a frame before applying animation\n if (componentState.unmounted === 'should-enter') {\n dontAnimate = style\n }\n\n const styles = animate\n const isExiting = Boolean(presence?.[1])\n const presenceContext = React.useContext(PresenceContext)\n const usePresenceValue = (presence || undefined) as any\n\n type UseMotiProps = Parameters<typeof useMotify>[0]\n\n // TODO moti is giving us type troubles, but this should work\n let transition = isHydrating\n ? { type: 'transition', duration: 0 }\n : (animations[animationKey as keyof typeof animations] as any)\n\n let hasClonedTransition = false\n\n if (Array.isArray(props.animation)) {\n const config = props.animation[1]\n if (config && typeof config === 'object') {\n for (const key in config) {\n const val = config[key]\n\n // performance - this seems to have (strangely) huge performance effect in uniswap\n // so instead of cloning up front, we clone only when we absolutely have to\n if (!hasClonedTransition) {\n transition = Object.assign({}, transition)\n hasClonedTransition = true\n }\n\n // referencing a pre-defined config\n if (typeof val === 'string') {\n transition[key] = animations[val]\n } else {\n transition[key] = val\n }\n }\n }\n }\n\n const motiProps = {\n animate: isExiting || componentState.unmounted === true ? {} : styles,\n transition: componentState.unmounted ? { duration: 0 } : transition,\n usePresenceValue,\n presenceContext,\n exit: isExiting ? styles : undefined,\n } satisfies UseMotiProps\n\n const moti = useMotify(motiProps)\n\n if (\n process.env.NODE_ENV === 'development' &&\n props['debug'] &&\n props['debug'] !== 'profile'\n ) {\n console.info(`useMotify(`, JSON.stringify(motiProps, null, 2) + ')', {\n 'componentState.unmounted': componentState.unmounted,\n motiProps,\n moti,\n style: [dontAnimate, moti.style],\n })\n }\n\n return {\n style: [dontAnimate, moti.style],\n }\n },\n }\n}\n"
|
|
10
|
+
"import { PresenceContext, ResetPresence, usePresence } from '@tamagui/use-presence'\nimport {\n getSplitStyles,\n hooks,\n isWeb,\n Text,\n useComposedRefs,\n useThemeWithState,\n View,\n type AnimationDriver,\n type UniversalAnimatedNumber,\n} from '@tamagui/web'\nimport type { TransitionConfig } from 'moti'\nimport { useMotify } from 'moti/author'\nimport type { CSSProperties } from 'react'\nimport React, { forwardRef, useMemo, useRef } from 'react'\nimport type { TextStyle } from 'react-native'\nimport type { SharedValue } from 'react-native-reanimated'\nimport Animated, {\n cancelAnimation,\n runOnJS,\n useAnimatedReaction,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withSpring,\n withTiming,\n} from 'react-native-reanimated'\n\ntype ReanimatedAnimatedNumber = SharedValue<number>\n\n// this is our own custom reanimated animated component so we can allow data- attributes, className etc\n// this should ultimately be merged with react-native-web-lite\n\nfunction createTamaguiAnimatedComponent(defaultTag = 'div') {\n const isText = defaultTag === 'span'\n\n const Component = Animated.createAnimatedComponent(\n forwardRef((propsIn: any, ref) => {\n const { forwardedRef, animation, tag = defaultTag, ...propsRest } = propsIn\n const hostRef = useRef()\n const composedRefs = useComposedRefs(forwardedRef, ref, hostRef)\n const stateRef = useRef<any>()\n if (!stateRef.current) {\n stateRef.current = {\n get host() {\n return hostRef.current\n },\n }\n }\n\n const [_, state] = useThemeWithState({})\n\n // get styles but only inline style\n const result = getSplitStyles(\n propsRest,\n isText ? Text.staticConfig : View.staticConfig,\n state?.theme!,\n state?.name!,\n {\n unmounted: false,\n } as any,\n {\n isAnimated: false,\n noClass: true,\n }\n )\n\n const props = result.viewProps\n const Element = tag\n const transformedProps = hooks.usePropsTransform?.(tag, props, stateRef, false)\n\n return <Element {...transformedProps} ref={composedRefs} />\n })\n )\n Component['acceptTagProp'] = true\n return Component\n}\n\nconst AnimatedView = createTamaguiAnimatedComponent('div')\nconst AnimatedText = createTamaguiAnimatedComponent('span')\n\n// const AnimatedView = styled(View, {\n// disableClassName: true,\n// })\n\n// const AnimatedText = styled(Text, {\n// disableClassName: true,\n// })\n\nconst onlyAnimateKeys: { [key in keyof TextStyle | keyof CSSProperties]?: boolean } = {\n transform: true,\n opacity: true,\n height: true,\n width: true,\n backgroundColor: true,\n borderColor: true,\n borderLeftColor: true,\n borderRightColor: true,\n borderTopColor: true,\n borderBottomColor: true,\n borderRadius: true,\n borderTopLeftRadius: true,\n borderTopRightRadius: true,\n borderBottomLeftRadius: true,\n borderBottomRightRadius: true,\n borderLeftWidth: true,\n borderRightWidth: true,\n borderTopWidth: true,\n borderBottomWidth: true,\n color: true,\n left: true,\n right: true,\n top: true,\n bottom: true,\n fontSize: true,\n fontWeight: true,\n lineHeight: true,\n letterSpacing: true,\n}\n\nexport function createAnimations<A extends Record<string, TransitionConfig>>(\n animations: A\n): AnimationDriver<A> {\n return {\n View: isWeb ? AnimatedView : Animated.View,\n Text: isWeb ? AnimatedText : Animated.Text,\n // View: Animated.View,\n // Text: Animated.Text,\n isReactNative: true,\n animations,\n usePresence,\n ResetPresence,\n\n useAnimatedNumber(initial): UniversalAnimatedNumber<ReanimatedAnimatedNumber> {\n const sharedValue = useSharedValue(initial)\n\n return React.useMemo(\n () => ({\n getInstance() {\n 'worklet'\n return sharedValue\n },\n getValue() {\n 'worklet'\n return sharedValue.value\n },\n setValue(next, config = { type: 'spring' }, onFinish) {\n 'worklet'\n if (config.type === 'direct') {\n sharedValue.value = next\n onFinish?.()\n } else if (config.type === 'spring') {\n sharedValue.value = withSpring(\n next,\n config,\n onFinish\n ? () => {\n 'worklet'\n runOnJS(onFinish)()\n }\n : undefined\n )\n } else {\n sharedValue.value = withTiming(\n next,\n config,\n onFinish\n ? () => {\n 'worklet'\n runOnJS(onFinish)()\n }\n : undefined\n )\n }\n },\n stop() {\n 'worklet'\n cancelAnimation(sharedValue)\n },\n }),\n [sharedValue]\n )\n },\n\n useAnimatedNumberReaction({ value }, onValue) {\n const instance = value.getInstance()\n return useAnimatedReaction(\n () => {\n return instance.value\n },\n (next, prev) => {\n if (prev !== next) {\n // @nate what is the point of this hook? is this necessary?\n // without runOnJS, onValue would need to be a worklet\n runOnJS(onValue)(next)\n }\n },\n // dependency array is very important here\n [onValue, instance]\n )\n },\n\n /**\n * `getStyle` must be a worklet\n */\n useAnimatedNumberStyle(val, getStyle) {\n const instance = val.getInstance()\n\n // this seems wrong but it works\n const derivedValue = useDerivedValue(() => {\n return instance.value\n // dependency array is very important here\n }, [instance, getStyle])\n\n return useAnimatedStyle(() => {\n return getStyle(derivedValue.value)\n // dependency array is very important here\n }, [val, getStyle, derivedValue, instance])\n },\n\n useAnimations: (animationProps) => {\n const { props, presence, style, componentState } = animationProps\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 // this memo is very important for performance, there's a big cost to\n // updating these values every render\n const { dontAnimate, motiProps } = useMemo(() => {\n let animate = {}\n let dontAnimate = {}\n\n if (disableAnimation) {\n dontAnimate = style\n } else {\n const animateOnly = props.animateOnly as string[]\n for (const key in style) {\n const value = style[key]\n if (\n !onlyAnimateKeys[key] ||\n value === 'auto' ||\n (typeof value === 'string' && value.startsWith('calc')) ||\n (animateOnly && !animateOnly.includes(key))\n ) {\n dontAnimate[key] = value\n } else {\n animate[key] = value\n }\n }\n }\n\n // if we don't do this moti seems to flicker a frame before applying animation\n if (componentState.unmounted === 'should-enter') {\n dontAnimate = style\n }\n\n const styles = animate\n const isExiting = Boolean(presence?.[1])\n const usePresenceValue = (presence || undefined) as any\n\n type UseMotiProps = Parameters<typeof useMotify>[0]\n\n // TODO moti is giving us type troubles, but this should work\n let transition = isHydrating\n ? { type: 'transition', duration: 0 }\n : (animations[animationKey as keyof typeof animations] as any)\n\n let hasClonedTransition = false\n\n if (Array.isArray(props.animation)) {\n const config = props.animation[1]\n if (config && typeof config === 'object') {\n for (const key in config) {\n const val = config[key]\n\n // performance - this seems to have (strangely) huge performance effect in uniswap\n // so instead of cloning up front, we clone only when we absolutely have to\n if (!hasClonedTransition) {\n transition = Object.assign({}, transition)\n hasClonedTransition = true\n }\n\n // referencing a pre-defined config\n if (typeof val === 'string') {\n transition[key] = animations[val]\n } else {\n transition[key] = val\n }\n }\n }\n }\n\n return {\n dontAnimate,\n motiProps: {\n animate: isExiting || componentState.unmounted === true ? {} : styles,\n transition: componentState.unmounted ? { duration: 0 } : transition,\n usePresenceValue,\n presenceContext,\n exit: isExiting ? styles : undefined,\n } satisfies UseMotiProps,\n }\n }, [animationKey, componentState.unmounted, JSON.stringify(style), presenceContext])\n\n const moti = useMotify(motiProps)\n\n if (\n process.env.NODE_ENV === 'development' &&\n props['debug'] &&\n props['debug'] !== 'profile'\n ) {\n console.info(`useMotify(`, JSON.stringify(motiProps, null, 2) + ')', {\n 'componentState.unmounted': componentState.unmounted,\n motiProps,\n moti,\n style: [dontAnimate, moti.style],\n })\n }\n\n return {\n style: [dontAnimate, moti.style],\n }\n },\n }\n}\n"
|
|
11
11
|
],
|
|
12
12
|
"version": 3
|
|
13
13
|
}
|