motion-on-native 1.0.7 → 1.1.1

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.
Files changed (4) hide show
  1. package/LICENSE +20 -21
  2. package/lib/index.d.ts +53 -19
  3. package/lib/index.js +401 -272
  4. package/package.json +54 -54
package/LICENSE CHANGED
@@ -1,21 +1,20 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Mohd Bilal
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Mohd Bilal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/lib/index.d.ts CHANGED
@@ -1,31 +1,68 @@
1
1
  import React from 'react';
2
- import { ViewStyle } from 'react-native';
2
+ import { View, ViewStyle } from 'react-native';
3
3
  export interface AnimationProps {
4
4
  opacity?: number;
5
5
  x?: number;
6
6
  y?: number;
7
+ z?: number;
7
8
  scale?: number;
9
+ scaleX?: number;
10
+ scaleY?: number;
8
11
  rotate?: string;
12
+ rotateX?: string;
13
+ rotateY?: string;
14
+ rotateZ?: string;
15
+ skewX?: string;
16
+ skewY?: string;
9
17
  width?: number;
10
18
  height?: number;
11
- borderRadius?: number;
12
- backgroundColor?: string;
19
+ minWidth?: number;
20
+ minHeight?: number;
21
+ maxWidth?: number;
22
+ maxHeight?: number;
13
23
  margin?: number;
14
24
  marginTop?: number;
15
25
  marginBottom?: number;
16
26
  marginLeft?: number;
17
27
  marginRight?: number;
28
+ marginHorizontal?: number;
29
+ marginVertical?: number;
18
30
  padding?: number;
19
31
  paddingTop?: number;
20
32
  paddingBottom?: number;
21
33
  paddingLeft?: number;
22
34
  paddingRight?: number;
35
+ paddingHorizontal?: number;
36
+ paddingVertical?: number;
37
+ borderRadius?: number;
38
+ borderTopLeftRadius?: number;
39
+ borderTopRightRadius?: number;
40
+ borderBottomLeftRadius?: number;
41
+ borderBottomRightRadius?: number;
23
42
  borderWidth?: number;
43
+ borderTopWidth?: number;
44
+ borderBottomWidth?: number;
45
+ borderLeftWidth?: number;
46
+ borderRightWidth?: number;
24
47
  borderColor?: string;
48
+ borderTopColor?: string;
49
+ borderBottomColor?: string;
50
+ borderLeftColor?: string;
51
+ borderRightColor?: string;
52
+ backgroundColor?: string;
53
+ color?: string;
25
54
  top?: number;
26
55
  bottom?: number;
27
56
  left?: number;
28
57
  right?: number;
58
+ shadowColor?: string;
59
+ shadowOffset?: {
60
+ width: number;
61
+ height: number;
62
+ };
63
+ shadowOpacity?: number;
64
+ shadowRadius?: number;
65
+ elevation?: number;
29
66
  }
30
67
  export interface TransitionProps {
31
68
  type?: 'spring' | 'timing';
@@ -33,31 +70,28 @@ export interface TransitionProps {
33
70
  damping?: number;
34
71
  stiffness?: number;
35
72
  mass?: number;
73
+ delay?: number;
74
+ ease?: string;
36
75
  }
37
76
  export interface MotionComponentProps {
38
- initial?: AnimationProps;
77
+ initial?: AnimationProps | false;
39
78
  animate?: AnimationProps;
40
79
  exit?: AnimationProps;
41
80
  transition?: TransitionProps;
42
81
  shouldExit?: boolean;
43
82
  onExitComplete?: () => void;
83
+ whileHover?: AnimationProps;
84
+ whileTap?: AnimationProps;
85
+ whileFocus?: AnimationProps;
86
+ layout?: boolean;
87
+ layoutId?: string;
44
88
  style?: ViewStyle;
45
89
  children?: React.ReactNode;
46
90
  }
47
91
  export declare const NativeMotion: {
48
- View: (props: MotionComponentProps & import("react-native").ViewProps) => React.FunctionComponentElement<{
49
- style: any[];
50
- } & Omit<MotionComponentProps & import("react-native").ViewProps, "style" | "animate" | "initial" | "exit" | "transition" | "children" | "shouldExit" | "onExitComplete">> | null;
51
- Text: (props: MotionComponentProps & import("react-native").TextProps) => React.FunctionComponentElement<{
52
- style: any[];
53
- } & Omit<MotionComponentProps & import("react-native").TextProps, "style" | "animate" | "initial" | "exit" | "transition" | "children" | "shouldExit" | "onExitComplete">> | null;
54
- Image: (props: MotionComponentProps & import("react-native").ImageProps) => React.FunctionComponentElement<{
55
- style: any[];
56
- } & Omit<MotionComponentProps & import("react-native").ImageProps, "style" | "animate" | "initial" | "exit" | "transition" | "children" | "shouldExit" | "onExitComplete">> | null;
57
- TextInput: (props: MotionComponentProps & import("react-native").TextInputProps) => React.FunctionComponentElement<{
58
- style: any[];
59
- } & Omit<MotionComponentProps & import("react-native").TextInputProps, "style" | "animate" | "initial" | "exit" | "transition" | "children" | "shouldExit" | "onExitComplete">> | null;
60
- TouchableOpacity: (props: MotionComponentProps & import("react-native").TouchableOpacityProps) => React.FunctionComponentElement<{
61
- style: any[];
62
- } & Omit<MotionComponentProps & import("react-native").TouchableOpacityProps, "style" | "animate" | "initial" | "exit" | "transition" | "children" | "shouldExit" | "onExitComplete">> | null;
92
+ View: (props: MotionComponentProps & import("react-native").ViewProps) => React.ReactElement<import("react-native-reanimated").AnimateProps<any>, string | React.JSXElementConstructor<any>> | null;
93
+ Text: (props: MotionComponentProps & import("react-native").TextProps) => React.ReactElement<import("react-native-reanimated").AnimateProps<any>, string | React.JSXElementConstructor<any>> | null;
94
+ Image: (props: MotionComponentProps & import("react-native").ImageProps) => React.ReactElement<import("react-native-reanimated").AnimateProps<any>, string | React.JSXElementConstructor<any>> | null;
95
+ TextInput: (props: MotionComponentProps & import("react-native").TextInputProps) => React.ReactElement<import("react-native-reanimated").AnimateProps<any>, string | React.JSXElementConstructor<any>> | null;
96
+ TouchableOpacity: (props: MotionComponentProps & import("react-native").TouchableOpacityProps & React.RefAttributes<View>) => React.ReactElement<import("react-native-reanimated").AnimateProps<any>, string | React.JSXElementConstructor<any>> | null;
63
97
  };
package/lib/index.js CHANGED
@@ -47,292 +47,390 @@ Object.defineProperty(exports, "__esModule", { value: true });
47
47
  exports.NativeMotion = void 0;
48
48
  const react_1 = __importStar(require("react"));
49
49
  const react_native_1 = require("react-native");
50
- // @ts-ignore
51
50
  const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
51
+ const DEFAULT_TRANSITION = {
52
+ type: 'spring',
53
+ damping: 15,
54
+ stiffness: 100,
55
+ duration: 300,
56
+ };
52
57
  function createMotionComponent(Component) {
53
58
  return function MotionComponent(props) {
54
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
55
- const { initial = {}, animate = {}, exit = {}, transition = {}, style = {}, children, shouldExit = false, onExitComplete = () => { } } = props, rest = __rest(props, ["initial", "animate", "exit", "transition", "style", "children", "shouldExit", "onExitComplete"]);
59
+ const { initial = {}, animate = {}, exit = {}, transition = DEFAULT_TRANSITION, shouldExit = false, onExitComplete, whileHover, whileTap, whileFocus, layout, layoutId, style = {}, children } = props, rest = __rest(props, ["initial", "animate", "exit", "transition", "shouldExit", "onExitComplete", "whileHover", "whileTap", "whileFocus", "layout", "layoutId", "style", "children"]);
56
60
  const [isPresent, setIsPresent] = (0, react_1.useState)(true);
57
- const [hasExited, setHasExited] = (0, react_1.useState)(false);
58
- const opacity = (0, react_native_reanimated_1.useSharedValue)((_a = initial.opacity) !== null && _a !== void 0 ? _a : 1);
59
- const translateX = (0, react_native_reanimated_1.useSharedValue)((_b = initial.x) !== null && _b !== void 0 ? _b : 0);
60
- const translateY = (0, react_native_reanimated_1.useSharedValue)((_c = initial.y) !== null && _c !== void 0 ? _c : 0);
61
- const scale = (0, react_native_reanimated_1.useSharedValue)((_d = initial.scale) !== null && _d !== void 0 ? _d : 1);
62
- const rotate = (0, react_native_reanimated_1.useSharedValue)((_e = initial.rotate) !== null && _e !== void 0 ? _e : '0deg');
63
- const width = (0, react_native_reanimated_1.useSharedValue)((_f = initial.width) !== null && _f !== void 0 ? _f : null);
64
- const height = (0, react_native_reanimated_1.useSharedValue)((_g = initial.height) !== null && _g !== void 0 ? _g : null);
65
- const borderRadius = (0, react_native_reanimated_1.useSharedValue)((_h = initial.borderRadius) !== null && _h !== void 0 ? _h : null);
66
- const backgroundColor = (0, react_native_reanimated_1.useSharedValue)((_j = initial.backgroundColor) !== null && _j !== void 0 ? _j : null);
67
- const margin = (0, react_native_reanimated_1.useSharedValue)((_k = initial.margin) !== null && _k !== void 0 ? _k : null);
68
- const marginTop = (0, react_native_reanimated_1.useSharedValue)((_l = initial.marginTop) !== null && _l !== void 0 ? _l : null);
69
- const marginBottom = (0, react_native_reanimated_1.useSharedValue)((_m = initial.marginBottom) !== null && _m !== void 0 ? _m : null);
70
- const marginLeft = (0, react_native_reanimated_1.useSharedValue)((_o = initial.marginLeft) !== null && _o !== void 0 ? _o : null);
71
- const marginRight = (0, react_native_reanimated_1.useSharedValue)((_p = initial.marginRight) !== null && _p !== void 0 ? _p : null);
72
- const padding = (0, react_native_reanimated_1.useSharedValue)((_q = initial.padding) !== null && _q !== void 0 ? _q : null);
73
- const paddingTop = (0, react_native_reanimated_1.useSharedValue)((_r = initial.paddingTop) !== null && _r !== void 0 ? _r : null);
74
- const paddingBottom = (0, react_native_reanimated_1.useSharedValue)((_s = initial.paddingBottom) !== null && _s !== void 0 ? _s : null);
75
- const paddingLeft = (0, react_native_reanimated_1.useSharedValue)((_t = initial.paddingLeft) !== null && _t !== void 0 ? _t : null);
76
- const paddingRight = (0, react_native_reanimated_1.useSharedValue)((_u = initial.paddingRight) !== null && _u !== void 0 ? _u : null);
77
- const borderWidth = (0, react_native_reanimated_1.useSharedValue)((_v = initial.borderWidth) !== null && _v !== void 0 ? _v : null);
78
- const borderColor = (0, react_native_reanimated_1.useSharedValue)((_w = initial.borderColor) !== null && _w !== void 0 ? _w : null);
79
- const top = (0, react_native_reanimated_1.useSharedValue)((_x = initial.top) !== null && _x !== void 0 ? _x : null);
80
- const bottom = (0, react_native_reanimated_1.useSharedValue)((_y = initial.bottom) !== null && _y !== void 0 ? _y : null);
81
- const left = (0, react_native_reanimated_1.useSharedValue)((_z = initial.left) !== null && _z !== void 0 ? _z : null);
82
- const right = (0, react_native_reanimated_1.useSharedValue)((_0 = initial.right) !== null && _0 !== void 0 ? _0 : null);
83
- const runAnim = (sharedVal, target) => {
84
- var _a;
85
- const config = transition.type === 'spring' ? (0, react_native_reanimated_1.withSpring)(target, transition) : (0, react_native_reanimated_1.withTiming)(target, { duration: (_a = transition.duration) !== null && _a !== void 0 ? _a : 300 });
86
- sharedVal.value = config;
61
+ const [hasAnimated, setHasAnimated] = (0, react_1.useState)(false);
62
+ const isExitingRef = (0, react_1.useRef)(false);
63
+ // Create shared values
64
+ const opacity = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('opacity', initial));
65
+ const x = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('x', initial));
66
+ const y = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('y', initial));
67
+ const z = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('z', initial));
68
+ const scale = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('scale', initial));
69
+ const scaleX = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('scaleX', initial));
70
+ const scaleY = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('scaleY', initial));
71
+ const rotate = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('rotate', initial));
72
+ const rotateX = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('rotateX', initial));
73
+ const rotateY = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('rotateY', initial));
74
+ const rotateZ = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('rotateZ', initial));
75
+ const skewX = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('skewX', initial));
76
+ const skewY = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('skewY', initial));
77
+ // Layout properties
78
+ const width = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('width', initial));
79
+ const height = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('height', initial));
80
+ const minWidth = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('minWidth', initial));
81
+ const minHeight = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('minHeight', initial));
82
+ const maxWidth = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('maxWidth', initial));
83
+ const maxHeight = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('maxHeight', initial));
84
+ // Spacing properties
85
+ const margin = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('margin', initial));
86
+ const marginTop = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('marginTop', initial));
87
+ const marginBottom = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('marginBottom', initial));
88
+ const marginLeft = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('marginLeft', initial));
89
+ const marginRight = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('marginRight', initial));
90
+ const marginHorizontal = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('marginHorizontal', initial));
91
+ const marginVertical = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('marginVertical', initial));
92
+ const padding = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('padding', initial));
93
+ const paddingTop = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('paddingTop', initial));
94
+ const paddingBottom = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('paddingBottom', initial));
95
+ const paddingLeft = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('paddingLeft', initial));
96
+ const paddingRight = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('paddingRight', initial));
97
+ const paddingHorizontal = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('paddingHorizontal', initial));
98
+ const paddingVertical = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('paddingVertical', initial));
99
+ // Border properties
100
+ const borderRadius = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderRadius', initial));
101
+ const borderTopLeftRadius = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderTopLeftRadius', initial));
102
+ const borderTopRightRadius = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderTopRightRadius', initial));
103
+ const borderBottomLeftRadius = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderBottomLeftRadius', initial));
104
+ const borderBottomRightRadius = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderBottomRightRadius', initial));
105
+ const borderWidth = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderWidth', initial));
106
+ const borderTopWidth = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderTopWidth', initial));
107
+ const borderBottomWidth = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderBottomWidth', initial));
108
+ const borderLeftWidth = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderLeftWidth', initial));
109
+ const borderRightWidth = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderRightWidth', initial));
110
+ const borderColor = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderColor', initial));
111
+ const borderTopColor = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderTopColor', initial));
112
+ const borderBottomColor = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderBottomColor', initial));
113
+ const borderLeftColor = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderLeftColor', initial));
114
+ const borderRightColor = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('borderRightColor', initial));
115
+ // Color properties
116
+ const backgroundColor = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('backgroundColor', initial));
117
+ const color = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('color', initial));
118
+ // Position properties
119
+ const top = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('top', initial));
120
+ const bottom = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('bottom', initial));
121
+ const left = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('left', initial));
122
+ const right = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('right', initial));
123
+ // Shadow properties
124
+ const shadowColor = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('shadowColor', initial));
125
+ const shadowOffset = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('shadowOffset', initial));
126
+ const shadowOpacity = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('shadowOpacity', initial));
127
+ const shadowRadius = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('shadowRadius', initial));
128
+ const elevation = (0, react_native_reanimated_1.useSharedValue)(getInitialValue('elevation', initial));
129
+ // Animation helper
130
+ const animateToValues = (targetValues, transitionConfig = transition) => {
131
+ Object.entries(targetValues).forEach(([key, value]) => {
132
+ var _a, _b, _c, _d;
133
+ if (value !== undefined) {
134
+ const sharedValue = getSharedValue(key);
135
+ if (sharedValue) {
136
+ const config = transitionConfig.type === 'spring'
137
+ ? (0, react_native_reanimated_1.withSpring)(value, {
138
+ damping: (_a = transitionConfig.damping) !== null && _a !== void 0 ? _a : DEFAULT_TRANSITION.damping,
139
+ stiffness: (_b = transitionConfig.stiffness) !== null && _b !== void 0 ? _b : DEFAULT_TRANSITION.stiffness,
140
+ mass: (_c = transitionConfig.mass) !== null && _c !== void 0 ? _c : 1,
141
+ })
142
+ : (0, react_native_reanimated_1.withTiming)(value, {
143
+ duration: (_d = transitionConfig.duration) !== null && _d !== void 0 ? _d : DEFAULT_TRANSITION.duration,
144
+ });
145
+ if (transitionConfig.delay) {
146
+ setTimeout(() => {
147
+ sharedValue.value = config;
148
+ }, transitionConfig.delay);
149
+ }
150
+ else {
151
+ sharedValue.value = config;
152
+ }
153
+ }
154
+ }
155
+ });
156
+ };
157
+ // Get shared value by key
158
+ const getSharedValue = (key) => {
159
+ switch (key) {
160
+ // Transform properties
161
+ case 'opacity': return opacity;
162
+ case 'x': return x;
163
+ case 'y': return y;
164
+ case 'z': return z;
165
+ case 'scale': return scale;
166
+ case 'scaleX': return scaleX;
167
+ case 'scaleY': return scaleY;
168
+ case 'rotate': return rotate;
169
+ case 'rotateX': return rotateX;
170
+ case 'rotateY': return rotateY;
171
+ case 'rotateZ': return rotateZ;
172
+ case 'skewX': return skewX;
173
+ case 'skewY': return skewY;
174
+ // Layout properties
175
+ case 'width': return width;
176
+ case 'height': return height;
177
+ case 'minWidth': return minWidth;
178
+ case 'minHeight': return minHeight;
179
+ case 'maxWidth': return maxWidth;
180
+ case 'maxHeight': return maxHeight;
181
+ // Spacing properties
182
+ case 'margin': return margin;
183
+ case 'marginTop': return marginTop;
184
+ case 'marginBottom': return marginBottom;
185
+ case 'marginLeft': return marginLeft;
186
+ case 'marginRight': return marginRight;
187
+ case 'marginHorizontal': return marginHorizontal;
188
+ case 'marginVertical': return marginVertical;
189
+ case 'padding': return padding;
190
+ case 'paddingTop': return paddingTop;
191
+ case 'paddingBottom': return paddingBottom;
192
+ case 'paddingLeft': return paddingLeft;
193
+ case 'paddingRight': return paddingRight;
194
+ case 'paddingHorizontal': return paddingHorizontal;
195
+ case 'paddingVertical': return paddingVertical;
196
+ // Border properties
197
+ case 'borderRadius': return borderRadius;
198
+ case 'borderTopLeftRadius': return borderTopLeftRadius;
199
+ case 'borderTopRightRadius': return borderTopRightRadius;
200
+ case 'borderBottomLeftRadius': return borderBottomLeftRadius;
201
+ case 'borderBottomRightRadius': return borderBottomRightRadius;
202
+ case 'borderWidth': return borderWidth;
203
+ case 'borderTopWidth': return borderTopWidth;
204
+ case 'borderBottomWidth': return borderBottomWidth;
205
+ case 'borderLeftWidth': return borderLeftWidth;
206
+ case 'borderRightWidth': return borderRightWidth;
207
+ case 'borderColor': return borderColor;
208
+ case 'borderTopColor': return borderTopColor;
209
+ case 'borderBottomColor': return borderBottomColor;
210
+ case 'borderLeftColor': return borderLeftColor;
211
+ case 'borderRightColor': return borderRightColor;
212
+ // Color properties
213
+ case 'backgroundColor': return backgroundColor;
214
+ case 'color': return color;
215
+ // Position properties
216
+ case 'top': return top;
217
+ case 'bottom': return bottom;
218
+ case 'left': return left;
219
+ case 'right': return right;
220
+ // Shadow properties
221
+ case 'shadowColor': return shadowColor;
222
+ case 'shadowOffset': return shadowOffset;
223
+ case 'shadowOpacity': return shadowOpacity;
224
+ case 'shadowRadius': return shadowRadius;
225
+ case 'elevation': return elevation;
226
+ default: return null;
227
+ }
87
228
  };
229
+ // Mount animation: initial -> animate
88
230
  (0, react_1.useEffect)(() => {
89
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
90
- opacity.value = (_a = initial.opacity) !== null && _a !== void 0 ? _a : 1;
91
- translateX.value = (_b = initial.x) !== null && _b !== void 0 ? _b : 0;
92
- translateY.value = (_c = initial.y) !== null && _c !== void 0 ? _c : 0;
93
- scale.value = (_d = initial.scale) !== null && _d !== void 0 ? _d : 1;
94
- rotate.value = (_e = initial.rotate) !== null && _e !== void 0 ? _e : '0deg';
95
- width.value = (_f = initial.width) !== null && _f !== void 0 ? _f : null;
96
- height.value = (_g = initial.height) !== null && _g !== void 0 ? _g : null;
97
- borderRadius.value = (_h = initial.borderRadius) !== null && _h !== void 0 ? _h : null;
98
- backgroundColor.value = (_j = initial.backgroundColor) !== null && _j !== void 0 ? _j : null;
99
- margin.value = (_k = initial.margin) !== null && _k !== void 0 ? _k : null;
100
- marginTop.value = (_l = initial.marginTop) !== null && _l !== void 0 ? _l : null;
101
- marginBottom.value = (_m = initial.marginBottom) !== null && _m !== void 0 ? _m : null;
102
- marginLeft.value = (_o = initial.marginLeft) !== null && _o !== void 0 ? _o : null;
103
- marginRight.value = (_p = initial.marginRight) !== null && _p !== void 0 ? _p : null;
104
- padding.value = (_q = initial.padding) !== null && _q !== void 0 ? _q : null;
105
- paddingTop.value = (_r = initial.paddingTop) !== null && _r !== void 0 ? _r : null;
106
- paddingBottom.value = (_s = initial.paddingBottom) !== null && _s !== void 0 ? _s : null;
107
- paddingLeft.value = (_t = initial.paddingLeft) !== null && _t !== void 0 ? _t : null;
108
- paddingRight.value = (_u = initial.paddingRight) !== null && _u !== void 0 ? _u : null;
109
- borderWidth.value = (_v = initial.borderWidth) !== null && _v !== void 0 ? _v : null;
110
- borderColor.value = (_w = initial.borderColor) !== null && _w !== void 0 ? _w : null;
111
- top.value = (_x = initial.top) !== null && _x !== void 0 ? _x : null;
112
- bottom.value = (_y = initial.bottom) !== null && _y !== void 0 ? _y : null;
113
- left.value = (_z = initial.left) !== null && _z !== void 0 ? _z : null;
114
- right.value = (_0 = initial.right) !== null && _0 !== void 0 ? _0 : null;
115
- }, [initial.opacity, initial.x, initial.y, initial.scale, initial.rotate, initial.width, initial.height, initial.borderRadius, initial.backgroundColor, initial.margin, initial.marginTop, initial.marginBottom, initial.marginLeft, initial.marginRight, initial.padding, initial.paddingTop, initial.paddingBottom, initial.paddingLeft, initial.paddingRight, initial.borderWidth, initial.borderColor, initial.top, initial.bottom, initial.left, initial.right]);
231
+ if (!hasAnimated && !isExitingRef.current) {
232
+ // Set initial values immediately
233
+ if (initial !== false) {
234
+ Object.entries(initial).forEach(([key, value]) => {
235
+ const sharedValue = getSharedValue(key);
236
+ if (sharedValue && value !== undefined) {
237
+ sharedValue.value = value;
238
+ }
239
+ });
240
+ }
241
+ // Animate to target values
242
+ const timer = setTimeout(() => {
243
+ if (!isExitingRef.current) {
244
+ animateToValues(animate);
245
+ setHasAnimated(true);
246
+ }
247
+ }, 16);
248
+ return () => clearTimeout(timer);
249
+ }
250
+ return undefined;
251
+ }, []);
252
+ // Handle animate prop changes
116
253
  (0, react_1.useEffect)(() => {
117
- var _a, _b, _c, _d, _e;
118
- runAnim(opacity, (_a = animate.opacity) !== null && _a !== void 0 ? _a : opacity.value);
119
- runAnim(translateX, (_b = animate.x) !== null && _b !== void 0 ? _b : translateX.value);
120
- runAnim(translateY, (_c = animate.y) !== null && _c !== void 0 ? _c : translateY.value);
121
- runAnim(scale, (_d = animate.scale) !== null && _d !== void 0 ? _d : scale.value);
122
- runAnim(rotate, (_e = animate.rotate) !== null && _e !== void 0 ? _e : rotate.value);
123
- if (animate.width !== undefined)
124
- runAnim(width, animate.width);
125
- if (animate.height !== undefined)
126
- runAnim(height, animate.height);
127
- if (animate.borderRadius !== undefined)
128
- runAnim(borderRadius, animate.borderRadius);
129
- if (animate.backgroundColor !== undefined)
130
- runAnim(backgroundColor, animate.backgroundColor);
131
- if (animate.margin !== undefined)
132
- runAnim(margin, animate.margin);
133
- if (animate.marginTop !== undefined)
134
- runAnim(marginTop, animate.marginTop);
135
- if (animate.marginBottom !== undefined)
136
- runAnim(marginBottom, animate.marginBottom);
137
- if (animate.marginLeft !== undefined)
138
- runAnim(marginLeft, animate.marginLeft);
139
- if (animate.marginRight !== undefined)
140
- runAnim(marginRight, animate.marginRight);
141
- if (animate.padding !== undefined)
142
- runAnim(padding, animate.padding);
143
- if (animate.paddingTop !== undefined)
144
- runAnim(paddingTop, animate.paddingTop);
145
- if (animate.paddingBottom !== undefined)
146
- runAnim(paddingBottom, animate.paddingBottom);
147
- if (animate.paddingLeft !== undefined)
148
- runAnim(paddingLeft, animate.paddingLeft);
149
- if (animate.paddingRight !== undefined)
150
- runAnim(paddingRight, animate.paddingRight);
151
- if (animate.borderWidth !== undefined)
152
- runAnim(borderWidth, animate.borderWidth);
153
- if (animate.borderColor !== undefined)
154
- runAnim(borderColor, animate.borderColor);
155
- if (animate.top !== undefined)
156
- runAnim(top, animate.top);
157
- if (animate.bottom !== undefined)
158
- runAnim(bottom, animate.bottom);
159
- if (animate.left !== undefined)
160
- runAnim(left, animate.left);
161
- if (animate.right !== undefined)
162
- runAnim(right, animate.right);
163
- }, [animate.opacity, animate.x, animate.y, animate.scale, animate.rotate, animate.width, animate.height, animate.borderRadius, animate.backgroundColor, animate.margin, animate.marginTop, animate.marginBottom, animate.marginLeft, animate.marginRight, animate.padding, animate.paddingTop, animate.paddingBottom, animate.paddingLeft, animate.paddingRight, animate.borderWidth, animate.borderColor, animate.top, animate.bottom, animate.left, animate.right]);
254
+ if (hasAnimated && !isExitingRef.current) {
255
+ animateToValues(animate);
256
+ }
257
+ }, [animate]);
258
+ // Handle shouldExit
164
259
  (0, react_1.useEffect)(() => {
165
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
166
- if (shouldExit && !hasExited && Object.keys(exit).length > 0) {
167
- setHasExited(true);
168
- runAnim(opacity, (_a = exit.opacity) !== null && _a !== void 0 ? _a : 0);
169
- runAnim(translateX, (_b = exit.x) !== null && _b !== void 0 ? _b : translateX.value);
170
- runAnim(translateY, (_c = exit.y) !== null && _c !== void 0 ? _c : translateY.value);
171
- runAnim(scale, (_d = exit.scale) !== null && _d !== void 0 ? _d : scale.value);
172
- runAnim(rotate, (_e = exit.rotate) !== null && _e !== void 0 ? _e : rotate.value);
173
- if (exit.width !== undefined)
174
- runAnim(width, exit.width);
175
- if (exit.height !== undefined)
176
- runAnim(height, exit.height);
177
- if (exit.borderRadius !== undefined)
178
- runAnim(borderRadius, exit.borderRadius);
179
- if (exit.backgroundColor !== undefined)
180
- runAnim(backgroundColor, exit.backgroundColor);
181
- if (exit.margin !== undefined)
182
- runAnim(margin, exit.margin);
183
- if (exit.marginTop !== undefined)
184
- runAnim(marginTop, exit.marginTop);
185
- if (exit.marginBottom !== undefined)
186
- runAnim(marginBottom, exit.marginBottom);
187
- if (exit.marginLeft !== undefined)
188
- runAnim(marginLeft, exit.marginLeft);
189
- if (exit.marginRight !== undefined)
190
- runAnim(marginRight, exit.marginRight);
191
- if (exit.padding !== undefined)
192
- runAnim(padding, exit.padding);
193
- if (exit.paddingTop !== undefined)
194
- runAnim(paddingTop, exit.paddingTop);
195
- if (exit.paddingBottom !== undefined)
196
- runAnim(paddingBottom, exit.paddingBottom);
197
- if (exit.paddingLeft !== undefined)
198
- runAnim(paddingLeft, exit.paddingLeft);
199
- if (exit.paddingRight !== undefined)
200
- runAnim(paddingRight, exit.paddingRight);
201
- if (exit.borderWidth !== undefined)
202
- runAnim(borderWidth, exit.borderWidth);
203
- if (exit.borderColor !== undefined)
204
- runAnim(borderColor, exit.borderColor);
205
- if (exit.top !== undefined)
206
- runAnim(top, exit.top);
207
- if (exit.bottom !== undefined)
208
- runAnim(bottom, exit.bottom);
209
- if (exit.left !== undefined)
210
- runAnim(left, exit.left);
211
- if (exit.right !== undefined)
212
- runAnim(right, exit.right);
213
- setTimeout(() => { setIsPresent(false); onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete(); }, (_f = transition.duration) !== null && _f !== void 0 ? _f : 300);
260
+ var _a;
261
+ if (shouldExit && !isExitingRef.current) {
262
+ isExitingRef.current = true;
263
+ if (exit && Object.keys(exit).length > 0) {
264
+ animateToValues(exit, transition);
265
+ const exitDuration = (_a = transition.duration) !== null && _a !== void 0 ? _a : 300;
266
+ setTimeout(() => {
267
+ setIsPresent(false);
268
+ if (onExitComplete) {
269
+ onExitComplete();
270
+ }
271
+ }, exitDuration);
272
+ }
273
+ else {
274
+ setIsPresent(false);
275
+ if (onExitComplete) {
276
+ onExitComplete();
277
+ }
278
+ }
214
279
  }
215
- else if (!shouldExit && hasExited) {
216
- setHasExited(false);
280
+ else if (!shouldExit && isExitingRef.current) {
281
+ // Re-entering: reset everything
282
+ isExitingRef.current = false;
217
283
  setIsPresent(true);
218
- opacity.value = (_g = initial.opacity) !== null && _g !== void 0 ? _g : 1;
219
- translateX.value = (_h = initial.x) !== null && _h !== void 0 ? _h : 0;
220
- translateY.value = (_j = initial.y) !== null && _j !== void 0 ? _j : 0;
221
- scale.value = (_k = initial.scale) !== null && _k !== void 0 ? _k : 1;
222
- rotate.value = (_l = initial.rotate) !== null && _l !== void 0 ? _l : '0deg';
223
- width.value = (_m = initial.width) !== null && _m !== void 0 ? _m : null;
224
- height.value = (_o = initial.height) !== null && _o !== void 0 ? _o : null;
225
- borderRadius.value = (_p = initial.borderRadius) !== null && _p !== void 0 ? _p : null;
226
- backgroundColor.value = (_q = initial.backgroundColor) !== null && _q !== void 0 ? _q : null;
227
- margin.value = (_r = initial.margin) !== null && _r !== void 0 ? _r : null;
228
- marginTop.value = (_s = initial.marginTop) !== null && _s !== void 0 ? _s : null;
229
- marginBottom.value = (_t = initial.marginBottom) !== null && _t !== void 0 ? _t : null;
230
- marginLeft.value = (_u = initial.marginLeft) !== null && _u !== void 0 ? _u : null;
231
- marginRight.value = (_v = initial.marginRight) !== null && _v !== void 0 ? _v : null;
232
- padding.value = (_w = initial.padding) !== null && _w !== void 0 ? _w : null;
233
- paddingTop.value = (_x = initial.paddingTop) !== null && _x !== void 0 ? _x : null;
234
- paddingBottom.value = (_y = initial.paddingBottom) !== null && _y !== void 0 ? _y : null;
235
- paddingLeft.value = (_z = initial.paddingLeft) !== null && _z !== void 0 ? _z : null;
236
- paddingRight.value = (_0 = initial.paddingRight) !== null && _0 !== void 0 ? _0 : null;
237
- borderWidth.value = (_1 = initial.borderWidth) !== null && _1 !== void 0 ? _1 : null;
238
- borderColor.value = (_2 = initial.borderColor) !== null && _2 !== void 0 ? _2 : null;
239
- top.value = (_3 = initial.top) !== null && _3 !== void 0 ? _3 : null;
240
- bottom.value = (_4 = initial.bottom) !== null && _4 !== void 0 ? _4 : null;
241
- left.value = (_5 = initial.left) !== null && _5 !== void 0 ? _5 : null;
242
- right.value = (_6 = initial.right) !== null && _6 !== void 0 ? _6 : null;
284
+ setHasAnimated(false);
285
+ // Reset to initial values
286
+ if (initial !== false) {
287
+ Object.entries(initial).forEach(([key, value]) => {
288
+ const sharedValue = getSharedValue(key);
289
+ if (sharedValue && value !== undefined) {
290
+ sharedValue.value = value;
291
+ }
292
+ });
293
+ }
294
+ // Animate to target after a frame
243
295
  setTimeout(() => {
244
- var _a, _b, _c, _d, _e;
245
- runAnim(opacity, (_a = animate.opacity) !== null && _a !== void 0 ? _a : opacity.value);
246
- runAnim(translateX, (_b = animate.x) !== null && _b !== void 0 ? _b : translateX.value);
247
- runAnim(translateY, (_c = animate.y) !== null && _c !== void 0 ? _c : translateY.value);
248
- runAnim(scale, (_d = animate.scale) !== null && _d !== void 0 ? _d : scale.value);
249
- runAnim(rotate, (_e = animate.rotate) !== null && _e !== void 0 ? _e : rotate.value);
250
- if (animate.width !== undefined)
251
- runAnim(width, animate.width);
252
- if (animate.height !== undefined)
253
- runAnim(height, animate.height);
254
- if (animate.borderRadius !== undefined)
255
- runAnim(borderRadius, animate.borderRadius);
256
- if (animate.backgroundColor !== undefined)
257
- runAnim(backgroundColor, animate.backgroundColor);
258
- if (animate.margin !== undefined)
259
- runAnim(margin, animate.margin);
260
- if (animate.marginTop !== undefined)
261
- runAnim(marginTop, animate.marginTop);
262
- if (animate.marginBottom !== undefined)
263
- runAnim(marginBottom, animate.marginBottom);
264
- if (animate.marginLeft !== undefined)
265
- runAnim(marginLeft, animate.marginLeft);
266
- if (animate.marginRight !== undefined)
267
- runAnim(marginRight, animate.marginRight);
268
- if (animate.padding !== undefined)
269
- runAnim(padding, animate.padding);
270
- if (animate.paddingTop !== undefined)
271
- runAnim(paddingTop, animate.paddingTop);
272
- if (animate.paddingBottom !== undefined)
273
- runAnim(paddingBottom, animate.paddingBottom);
274
- if (animate.paddingLeft !== undefined)
275
- runAnim(paddingLeft, animate.paddingLeft);
276
- if (animate.paddingRight !== undefined)
277
- runAnim(paddingRight, animate.paddingRight);
278
- if (animate.borderWidth !== undefined)
279
- runAnim(borderWidth, animate.borderWidth);
280
- if (animate.borderColor !== undefined)
281
- runAnim(borderColor, animate.borderColor);
282
- if (animate.top !== undefined)
283
- runAnim(top, animate.top);
284
- if (animate.bottom !== undefined)
285
- runAnim(bottom, animate.bottom);
286
- if (animate.left !== undefined)
287
- runAnim(left, animate.left);
288
- if (animate.right !== undefined)
289
- runAnim(right, animate.right);
290
- }, 50);
296
+ if (!isExitingRef.current) {
297
+ animateToValues(animate);
298
+ setHasAnimated(true);
299
+ }
300
+ }, 16);
291
301
  }
292
302
  }, [shouldExit]);
303
+ // Animated style
293
304
  const animatedStyle = (0, react_native_reanimated_1.useAnimatedStyle)(() => {
294
- const styleObj = { opacity: opacity.value, transform: [{ translateX: translateX.value }, { translateY: translateY.value }, { scale: scale.value }, { rotate: rotate.value }] };
295
- if (width.value !== null)
296
- styleObj.width = width.value;
297
- if (height.value !== null)
298
- styleObj.height = height.value;
299
- if (borderRadius.value !== null)
300
- styleObj.borderRadius = borderRadius.value;
301
- if (backgroundColor.value !== null)
302
- styleObj.backgroundColor = backgroundColor.value;
303
- if (margin.value !== null)
304
- styleObj.margin = margin.value;
305
- if (marginTop.value !== null)
306
- styleObj.marginTop = marginTop.value;
307
- if (marginBottom.value !== null)
308
- styleObj.marginBottom = marginBottom.value;
309
- if (marginLeft.value !== null)
310
- styleObj.marginLeft = marginLeft.value;
311
- if (marginRight.value !== null)
312
- styleObj.marginRight = marginRight.value;
313
- if (padding.value !== null)
314
- styleObj.padding = padding.value;
315
- if (paddingTop.value !== null)
316
- styleObj.paddingTop = paddingTop.value;
317
- if (paddingBottom.value !== null)
318
- styleObj.paddingBottom = paddingBottom.value;
319
- if (paddingLeft.value !== null)
320
- styleObj.paddingLeft = paddingLeft.value;
321
- if (paddingRight.value !== null)
322
- styleObj.paddingRight = paddingRight.value;
323
- if (borderWidth.value !== null)
324
- styleObj.borderWidth = borderWidth.value;
325
- if (borderColor.value !== null)
326
- styleObj.borderColor = borderColor.value;
327
- if (top.value !== null)
328
- styleObj.top = top.value;
329
- if (bottom.value !== null)
330
- styleObj.bottom = bottom.value;
331
- if (left.value !== null)
332
- styleObj.left = left.value;
333
- if (right.value !== null)
334
- styleObj.right = right.value;
335
- return styleObj;
305
+ const style = {};
306
+ const transform = [];
307
+ // Transform properties
308
+ style.opacity = opacity.value;
309
+ if (x.value !== 0)
310
+ transform.push({ translateX: x.value });
311
+ if (y.value !== 0)
312
+ transform.push({ translateY: y.value });
313
+ if (z.value !== 0)
314
+ transform.push({ translateZ: z.value });
315
+ if (scale.value !== 1)
316
+ transform.push({ scale: scale.value });
317
+ if (scaleX.value !== 1)
318
+ transform.push({ scaleX: scaleX.value });
319
+ if (scaleY.value !== 1)
320
+ transform.push({ scaleY: scaleY.value });
321
+ if (rotate.value !== '0deg')
322
+ transform.push({ rotate: rotate.value });
323
+ if (rotateX.value !== '0deg')
324
+ transform.push({ rotateX: rotateX.value });
325
+ if (rotateY.value !== '0deg')
326
+ transform.push({ rotateY: rotateY.value });
327
+ if (rotateZ.value !== '0deg')
328
+ transform.push({ rotateZ: rotateZ.value });
329
+ if (skewX.value !== '0deg')
330
+ transform.push({ skewX: skewX.value });
331
+ if (skewY.value !== '0deg')
332
+ transform.push({ skewY: skewY.value });
333
+ if (transform.length > 0)
334
+ style.transform = transform;
335
+ // Layout properties
336
+ if (width.value !== 0)
337
+ style.width = width.value;
338
+ if (height.value !== 0)
339
+ style.height = height.value;
340
+ if (minWidth.value !== 0)
341
+ style.minWidth = minWidth.value;
342
+ if (minHeight.value !== 0)
343
+ style.minHeight = minHeight.value;
344
+ if (maxWidth.value !== 0)
345
+ style.maxWidth = maxWidth.value;
346
+ if (maxHeight.value !== 0)
347
+ style.maxHeight = maxHeight.value;
348
+ // Spacing properties
349
+ if (margin.value !== 0)
350
+ style.margin = margin.value;
351
+ if (marginTop.value !== 0)
352
+ style.marginTop = marginTop.value;
353
+ if (marginBottom.value !== 0)
354
+ style.marginBottom = marginBottom.value;
355
+ if (marginLeft.value !== 0)
356
+ style.marginLeft = marginLeft.value;
357
+ if (marginRight.value !== 0)
358
+ style.marginRight = marginRight.value;
359
+ if (marginHorizontal.value !== 0)
360
+ style.marginHorizontal = marginHorizontal.value;
361
+ if (marginVertical.value !== 0)
362
+ style.marginVertical = marginVertical.value;
363
+ if (padding.value !== 0)
364
+ style.padding = padding.value;
365
+ if (paddingTop.value !== 0)
366
+ style.paddingTop = paddingTop.value;
367
+ if (paddingBottom.value !== 0)
368
+ style.paddingBottom = paddingBottom.value;
369
+ if (paddingLeft.value !== 0)
370
+ style.paddingLeft = paddingLeft.value;
371
+ if (paddingRight.value !== 0)
372
+ style.paddingRight = paddingRight.value;
373
+ if (paddingHorizontal.value !== 0)
374
+ style.paddingHorizontal = paddingHorizontal.value;
375
+ if (paddingVertical.value !== 0)
376
+ style.paddingVertical = paddingVertical.value;
377
+ // Border properties
378
+ if (borderRadius.value !== 0)
379
+ style.borderRadius = borderRadius.value;
380
+ if (borderTopLeftRadius.value !== 0)
381
+ style.borderTopLeftRadius = borderTopLeftRadius.value;
382
+ if (borderTopRightRadius.value !== 0)
383
+ style.borderTopRightRadius = borderTopRightRadius.value;
384
+ if (borderBottomLeftRadius.value !== 0)
385
+ style.borderBottomLeftRadius = borderBottomLeftRadius.value;
386
+ if (borderBottomRightRadius.value !== 0)
387
+ style.borderBottomRightRadius = borderBottomRightRadius.value;
388
+ if (borderWidth.value !== 0)
389
+ style.borderWidth = borderWidth.value;
390
+ if (borderTopWidth.value !== 0)
391
+ style.borderTopWidth = borderTopWidth.value;
392
+ if (borderBottomWidth.value !== 0)
393
+ style.borderBottomWidth = borderBottomWidth.value;
394
+ if (borderLeftWidth.value !== 0)
395
+ style.borderLeftWidth = borderLeftWidth.value;
396
+ if (borderRightWidth.value !== 0)
397
+ style.borderRightWidth = borderRightWidth.value;
398
+ if (borderColor.value !== 0)
399
+ style.borderColor = borderColor.value;
400
+ if (borderTopColor.value !== 0)
401
+ style.borderTopColor = borderTopColor.value;
402
+ if (borderBottomColor.value !== 0)
403
+ style.borderBottomColor = borderBottomColor.value;
404
+ if (borderLeftColor.value !== 0)
405
+ style.borderLeftColor = borderLeftColor.value;
406
+ if (borderRightColor.value !== 0)
407
+ style.borderRightColor = borderRightColor.value;
408
+ // Color properties
409
+ if (backgroundColor.value !== 0)
410
+ style.backgroundColor = backgroundColor.value;
411
+ if (color.value !== 0)
412
+ style.color = color.value;
413
+ // Position properties
414
+ if (top.value !== 0)
415
+ style.top = top.value;
416
+ if (bottom.value !== 0)
417
+ style.bottom = bottom.value;
418
+ if (left.value !== 0)
419
+ style.left = left.value;
420
+ if (right.value !== 0)
421
+ style.right = right.value;
422
+ // Shadow properties
423
+ if (shadowColor.value !== 0)
424
+ style.shadowColor = shadowColor.value;
425
+ if (shadowOffset.value !== 0)
426
+ style.shadowOffset = shadowOffset.value;
427
+ if (shadowOpacity.value !== 0)
428
+ style.shadowOpacity = shadowOpacity.value;
429
+ if (shadowRadius.value !== 0)
430
+ style.shadowRadius = shadowRadius.value;
431
+ if (elevation.value !== 0)
432
+ style.elevation = elevation.value;
433
+ return style;
336
434
  });
337
435
  const AnimatedComponent = react_native_reanimated_1.default.createAnimatedComponent(Component);
338
436
  if (!isPresent)
@@ -340,6 +438,37 @@ function createMotionComponent(Component) {
340
438
  return react_1.default.createElement(AnimatedComponent, Object.assign({ style: [style, animatedStyle] }, rest), children);
341
439
  };
342
440
  }
441
+ function getInitialValue(key, initial) {
442
+ if (initial === false) {
443
+ return getDefaultValue(key);
444
+ }
445
+ const value = initial[key];
446
+ return value !== undefined ? value : getDefaultValue(key);
447
+ }
448
+ function getDefaultValue(key) {
449
+ switch (key) {
450
+ case 'opacity':
451
+ case 'scale':
452
+ case 'scaleX':
453
+ case 'scaleY':
454
+ return 1;
455
+ case 'x':
456
+ case 'y':
457
+ case 'z':
458
+ return 0;
459
+ case 'rotate':
460
+ case 'rotateX':
461
+ case 'rotateY':
462
+ case 'rotateZ':
463
+ case 'skewX':
464
+ case 'skewY':
465
+ return '0deg';
466
+ case 'shadowOffset':
467
+ return { width: 0, height: 0 };
468
+ default:
469
+ return 0;
470
+ }
471
+ }
343
472
  exports.NativeMotion = {
344
473
  View: createMotionComponent(react_native_1.View),
345
474
  Text: createMotionComponent(react_native_1.Text),
package/package.json CHANGED
@@ -1,54 +1,54 @@
1
- {
2
- "name": "motion-on-native",
3
- "version": "1.0.7",
4
- "description": "Framer Motion-inspired animation library for React Native with Reanimated. Easy spring animations, gestures, and transitions for mobile apps.",
5
- "main": "lib/index.js",
6
- "types": "lib/index.d.ts",
7
- "scripts": {
8
- "build": "tsc",
9
- "prepare": "npm run build",
10
- "test": "echo \"Error: no test specified\" && exit 1"
11
- },
12
- "keywords": [
13
- "react-native",
14
- "framer-motion",
15
- "animation",
16
- "reanimated",
17
- "motion",
18
- "spring-animation",
19
- "mobile-animation",
20
- "react-native-animation",
21
- "gesture",
22
- "transition",
23
- "ui-animation",
24
- "native-animation",
25
- "ios",
26
- "android",
27
- "typescript"
28
- ],
29
- "author": "Mohd Bilal",
30
- "license": "MIT",
31
- "peerDependencies": {
32
- "react": ">=16.8.0",
33
- "react-native": ">=0.60.0",
34
- "react-native-reanimated": ">=3.0.0"
35
- },
36
- "devDependencies": {
37
- "@types/react": "^19.1.9",
38
- "@types/react-native": "^0.72.8",
39
- "typescript": "^5.0.0"
40
- },
41
- "files": [
42
- "lib",
43
- "README.md",
44
- "LICENSE"
45
- ],
46
- "repository": {
47
- "type": "git",
48
- "url": "https://github.com/mohd-Bilal-exe/motion-on-native.git"
49
- },
50
- "bugs": {
51
- "url": "https://github.com/mohd-Bilal-exe/motion-on-native/issues"
52
- },
53
- "homepage": "https://github.com/mohd-Bilal-exe/motion-on-native#readme"
54
- }
1
+ {
2
+ "name": "motion-on-native",
3
+ "version": "1.1.1",
4
+ "description": "Framer Motion-inspired animation library for React Native with Reanimated. Easy spring animations, gestures, and transitions for mobile apps.",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "prepare": "npm run build",
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ },
12
+ "keywords": [
13
+ "react-native",
14
+ "framer-motion",
15
+ "animation",
16
+ "reanimated",
17
+ "motion",
18
+ "spring-animation",
19
+ "mobile-animation",
20
+ "react-native-animation",
21
+ "gesture",
22
+ "transition",
23
+ "ui-animation",
24
+ "native-animation",
25
+ "ios",
26
+ "android",
27
+ "typescript"
28
+ ],
29
+ "author": "Mohd Bilal",
30
+ "license": "MIT",
31
+ "peerDependencies": {
32
+ "react": ">=16.8.0",
33
+ "react-native": ">=0.60.0",
34
+ "react-native-reanimated": ">=3.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "@types/react": "^19.1.9",
38
+ "@types/react-native": "^0.72.8",
39
+ "typescript": "^5.0.0"
40
+ },
41
+ "files": [
42
+ "lib",
43
+ "README.md",
44
+ "LICENSE"
45
+ ],
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/mohd-Bilal-exe/motion-on-native.git"
49
+ },
50
+ "bugs": {
51
+ "url": "https://github.com/mohd-Bilal-exe/motion-on-native/issues"
52
+ },
53
+ "homepage": "https://github.com/mohd-Bilal-exe/motion-on-native#readme"
54
+ }