@tamagui/animations-moti 1.74.2 → 1.74.4

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.
@@ -0,0 +1,102 @@
1
+ import { PresenceContext, usePresence } from "@tamagui/use-presence";
2
+ import { useMotify } from "moti/author";
3
+ import { useCallback, useContext, useMemo } from "react";
4
+ import Animated, {
5
+ cancelAnimation,
6
+ runOnJS,
7
+ useAnimatedReaction,
8
+ useAnimatedStyle,
9
+ useDerivedValue,
10
+ useSharedValue,
11
+ withSpring,
12
+ withTiming
13
+ } from "react-native-reanimated";
14
+ function createAnimations(animations) {
15
+ return {
16
+ View: Animated.View,
17
+ Text: Animated.Text,
18
+ isReactNative: !0,
19
+ keepStyleSSR: !0,
20
+ supportsCSSVars: !0,
21
+ animations,
22
+ usePresence,
23
+ useAnimatedNumber(initial) {
24
+ const sharedValue = useSharedValue(initial);
25
+ return useMemo(
26
+ () => ({
27
+ getInstance() {
28
+ "worklet";
29
+ return sharedValue;
30
+ },
31
+ getValue() {
32
+ "worklet";
33
+ return sharedValue.value;
34
+ },
35
+ setValue(next, config = { type: "spring" }) {
36
+ "worklet";
37
+ config.type === "direct" ? sharedValue.value = next : config.type === "spring" ? sharedValue.value = withSpring(next, config) : sharedValue.value = withTiming(next, config);
38
+ },
39
+ stop() {
40
+ "worklet";
41
+ cancelAnimation(sharedValue);
42
+ }
43
+ }),
44
+ [sharedValue]
45
+ );
46
+ },
47
+ useAnimatedNumberReaction({ value }, onValue) {
48
+ const instance = value.getInstance();
49
+ return useAnimatedReaction(
50
+ () => instance.value,
51
+ (next, prev) => {
52
+ prev !== next && runOnJS(onValue)(next);
53
+ },
54
+ // dependency array is very important here
55
+ [onValue, instance]
56
+ );
57
+ },
58
+ /**
59
+ * `getStyle` must be a worklet
60
+ */
61
+ useAnimatedNumberStyle(val, getStyle) {
62
+ const instance = val.getInstance(), derivedValue = useDerivedValue(() => instance.value, [instance, getStyle]);
63
+ return useAnimatedStyle(() => getStyle(derivedValue.value), [val, getStyle, derivedValue, instance]);
64
+ },
65
+ useAnimations: ({ props, presence, style, onDidAnimate }) => {
66
+ const animationKey = Array.isArray(props.animation) ? props.animation[0] : props.animation;
67
+ let animate, dontAnimate;
68
+ const animateOnly = props.animateOnly || ["transform", "opacity"];
69
+ if (animateOnly) {
70
+ animate = {}, dontAnimate = { ...style };
71
+ for (const key of animateOnly)
72
+ key in style && (animate[key] = style[key], delete dontAnimate[key]);
73
+ } else
74
+ animate = { ...style }, dontAnimate = {};
75
+ const animateStr = JSON.stringify(animate), styles = useMemo(() => JSON.parse(animateStr), [animateStr]), isExiting = !!presence?.[1], sendExitComplete = presence?.[1], transition = animations[animationKey], onDidAnimateCombined = useCallback(() => {
76
+ onDidAnimate?.(), sendExitComplete?.();
77
+ }, []), motiProps = {
78
+ animate: isExiting ? void 0 : styles,
79
+ transition,
80
+ onDidAnimate: onDidAnimateCombined,
81
+ usePresenceValue: presence,
82
+ presenceContext: useContext(PresenceContext),
83
+ exit: isExiting ? styles : void 0
84
+ }, moti = useMotify(motiProps);
85
+ return process.env.NODE_ENV === "development" && props.debug === "verbose" && console.log("Moti animation:", {
86
+ animate,
87
+ transition,
88
+ styles,
89
+ moti,
90
+ dontAnimate,
91
+ isExiting,
92
+ animateStr
93
+ }), {
94
+ style: [dontAnimate, moti.style]
95
+ };
96
+ }
97
+ };
98
+ }
99
+ export {
100
+ createAnimations
101
+ };
102
+ //# sourceMappingURL=createAnimations.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/createAnimations.tsx"],
4
+ "mappings": "AAAA,SAAS,iBAAiB,mBAAmB;AAG7C,SAAS,iBAAiB;AAC1B,SAAS,aAAa,YAAY,eAAe;AACjD,OAAO;AAAA,EAEL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIA,SAAS,iBACd,YACoB;AACpB,SAAO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AM,SAAS,IAC9C,MAAM,UAAU,CAAC,IACjB,MAAM;AAEV,UAAI,SACA;AAEJ,YAAM,cAAc,MAAM,eAAe,CAAC,aAAa,SAAS;AAChE,UAAI,aAAa;AACf,kBAAU,CAAC,GACX,cAAc,EAAE,GAAG,MAAM;AACzB,mBAAW,OAAO;AAChB,UAAM,OAAO,UACb,QAAQ,GAAG,IAAI,MAAM,GAAG,GACxB,OAAO,YAAY,GAAG;AAAA,MAE1B;AACE,kBAAU,EAAE,GAAG,MAAM,GACrB,cAAc,CAAC;AAKjB,YAAM,aAAa,KAAK,UAAU,OAAO,GACnC,SAAS,QAAQ,MAAM,KAAK,MAAM,UAAU,GAAG,CAAC,UAAU,CAAC,GAC3D,YAAY,EAAQ,WAAW,CAAC,GAChC,mBAAmB,WAAW,CAAC,GAC/B,aAAa,WAAW,YAAuC,GAE/D,uBAAuB,YAAY,MAAM;AAC7C,uBAAe,GACf,mBAAmB;AAAA,MACrB,GAAG,CAAC,CAAC,GAEC,YAAY;AAAA,QAChB,SAAS,YAAY,SAAY;AAAA,QACjC;AAAA,QACA,cAAc;AAAA,QACd,kBAAkB;AAAA,QAClB,iBAAiB,WAAW,eAAe;AAAA,QAC3C,MAAM,YAAY,SAAS;AAAA,MAC7B,GAEM,OAAO,UAAU,SAAS;AAEhC,aAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,UAAa,aAE/D,QAAQ,IAAI,mBAAmB;AAAA,QAC7B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC,GAGI;AAAA,QACL,OAAO,CAAC,aAAa,KAAK,KAAK;AAAA,MACjC;AAAA,IACF;AAAA,EACF;AACF;",
5
+ "names": []
6
+ }
@@ -0,0 +1,3 @@
1
+ import "./polyfill";
2
+ export * from "./createAnimations";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.tsx"],
4
+ "mappings": "AAAA,OAAO;AAEP,cAAc;",
5
+ "names": []
6
+ }
@@ -0,0 +1,2 @@
1
+ typeof requestAnimationFrame > "u" && (globalThis.requestAnimationFrame = setTimeout);
2
+ //# sourceMappingURL=polyfill.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/polyfill.ts"],
4
+ "mappings": "AACI,OAAO,wBAA0B,QACnC,WAAW,wBAA2B;",
5
+ "names": []
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/animations-moti",
3
- "version": "1.74.2",
3
+ "version": "1.74.4",
4
4
  "source": "src/index.ts",
5
5
  "license": "MIT",
6
6
  "types": "./types/index.d.ts",
@@ -12,12 +12,12 @@
12
12
  "dist"
13
13
  ],
14
14
  "dependencies": {
15
- "@tamagui/use-presence": "1.74.2",
16
- "@tamagui/web": "1.74.2",
15
+ "@tamagui/use-presence": "1.74.4",
16
+ "@tamagui/web": "1.74.4",
17
17
  "moti": "^0.25.3"
18
18
  },
19
19
  "devDependencies": {
20
- "@tamagui/build": "1.74.2",
20
+ "@tamagui/build": "1.74.4",
21
21
  "react-native-reanimated": "^3.3.0"
22
22
  },
23
23
  "scripts": {