motion-on-native 1.0.2

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/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # React Native Motion
2
+
3
+ Framer Motion-like animations for React Native using Reanimated.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install react-native-motion
9
+ # or
10
+ yarn add react-native-motion
11
+ ```
12
+
13
+ ## Prerequisites
14
+
15
+ This package requires:
16
+ - `react-native-reanimated` >= 3.0.0
17
+ - `react-native` >= 0.60.0
18
+ - `react` >= 16.8.0
19
+
20
+ ## Usage
21
+
22
+ ```tsx
23
+ import { NativeMotion } from 'react-native-motion';
24
+
25
+ // Basic animation
26
+ <NativeMotion.View
27
+ initial={{ opacity: 0, x: -100 }}
28
+ animate={{ opacity: 1, x: 0 }}
29
+ transition={{ type: 'spring', damping: 15 }}
30
+ >
31
+ <Text>Animated content</Text>
32
+ </NativeMotion.View>
33
+
34
+ // Exit animation
35
+ <NativeMotion.View
36
+ initial={{ opacity: 0, scale: 0.5 }}
37
+ animate={{ opacity: 1, scale: 1 }}
38
+ exit={{ opacity: 0, scale: 0 }}
39
+ shouldExit={shouldHide}
40
+ onExitComplete={() => console.log('Animation complete')}
41
+ >
42
+ <Text>Content with exit animation</Text>
43
+ </NativeMotion.View>
44
+ ```
45
+
46
+ ## Components
47
+
48
+ - `NativeMotion.View`
49
+ - `NativeMotion.Text`
50
+ - `NativeMotion.Image`
51
+ - `NativeMotion.TextInput`
52
+ - `NativeMotion.TouchableOpacity`
53
+
54
+ ## Animation Properties
55
+
56
+ - `opacity`: 0-1
57
+ - `x`, `y`: translation in pixels
58
+ - `scale`: size multiplier
59
+ - `rotate`: rotation (e.g., '45deg')
60
+ - `width`, `height`: dimensions in pixels
61
+ - `margin`, `marginTop`, `marginBottom`, `marginLeft`, `marginRight`
62
+ - `padding`, `paddingTop`, `paddingBottom`, `paddingLeft`, `paddingRight`
63
+ - `borderRadius`, `borderWidth`, `borderColor`
64
+ - `backgroundColor`: hex color
65
+ - `top`, `bottom`, `left`, `right`: positioning
66
+
67
+ ## Transition Types
68
+
69
+ ```tsx
70
+ // Spring animation
71
+ transition={{ type: 'spring', damping: 15, stiffness: 100 }}
72
+
73
+ // Timing animation
74
+ transition={{ type: 'timing', duration: 300 }}
75
+ ```
76
+
77
+ ## License
78
+
79
+ MIT
package/lib/index.d.ts ADDED
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import { ViewStyle } from 'react-native';
3
+ export interface AnimationProps {
4
+ opacity?: number;
5
+ x?: number;
6
+ y?: number;
7
+ scale?: number;
8
+ rotate?: string;
9
+ width?: number;
10
+ height?: number;
11
+ borderRadius?: number;
12
+ backgroundColor?: string;
13
+ margin?: number;
14
+ marginTop?: number;
15
+ marginBottom?: number;
16
+ marginLeft?: number;
17
+ marginRight?: number;
18
+ padding?: number;
19
+ paddingTop?: number;
20
+ paddingBottom?: number;
21
+ paddingLeft?: number;
22
+ paddingRight?: number;
23
+ borderWidth?: number;
24
+ borderColor?: string;
25
+ top?: number;
26
+ bottom?: number;
27
+ left?: number;
28
+ right?: number;
29
+ }
30
+ export interface TransitionProps {
31
+ type?: 'spring' | 'timing';
32
+ duration?: number;
33
+ damping?: number;
34
+ stiffness?: number;
35
+ mass?: number;
36
+ }
37
+ export interface MotionComponentProps {
38
+ initial?: AnimationProps;
39
+ animate?: AnimationProps;
40
+ exit?: AnimationProps;
41
+ transition?: TransitionProps;
42
+ shouldExit?: boolean;
43
+ onExitComplete?: () => void;
44
+ style?: ViewStyle;
45
+ children?: React.ReactNode;
46
+ }
47
+ 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;
63
+ };
package/lib/index.js ADDED
@@ -0,0 +1,349 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __rest = (this && this.__rest) || function (s, e) {
36
+ var t = {};
37
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
38
+ t[p] = s[p];
39
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
40
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
41
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
42
+ t[p[i]] = s[p[i]];
43
+ }
44
+ return t;
45
+ };
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ exports.NativeMotion = void 0;
48
+ const react_1 = __importStar(require("react"));
49
+ const react_native_1 = require("react-native");
50
+ // @ts-ignore
51
+ const react_native_reanimated_1 = __importStar(require("react-native-reanimated"));
52
+ function createMotionComponent(Component) {
53
+ 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"]);
56
+ 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;
87
+ };
88
+ (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]);
116
+ (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]);
164
+ (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);
214
+ }
215
+ else if (!shouldExit && hasExited) {
216
+ setHasExited(false);
217
+ 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;
243
+ 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);
291
+ }
292
+ }, [shouldExit]);
293
+ 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;
336
+ });
337
+ const AnimatedComponent = react_native_reanimated_1.default.createAnimatedComponent(Component);
338
+ if (!isPresent)
339
+ return null;
340
+ return react_1.default.createElement(AnimatedComponent, Object.assign({ style: [style, animatedStyle] }, rest), children);
341
+ };
342
+ }
343
+ exports.NativeMotion = {
344
+ View: createMotionComponent(react_native_1.View),
345
+ Text: createMotionComponent(react_native_1.Text),
346
+ Image: createMotionComponent(react_native_1.Image),
347
+ TextInput: createMotionComponent(react_native_1.TextInput),
348
+ TouchableOpacity: createMotionComponent(react_native_1.TouchableOpacity),
349
+ };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "motion-on-native",
3
+ "version": "1.0.2",
4
+ "description": "Framer Motion-like animations for React Native using Reanimated",
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
+ "animation",
15
+ "framer-motion",
16
+ "reanimated",
17
+ "motion"
18
+ ],
19
+ "author": "Mohd Bilal",
20
+ "license": "MIT",
21
+ "peerDependencies": {
22
+ "react": "^19.1.1",
23
+ "react-native": ">=0.60.0",
24
+ "react-native-reanimated": ">=3.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@types/react": "^19.1.9",
28
+ "@types/react-native": "^0.72.8",
29
+ "typescript": "^5.0.0"
30
+ },
31
+ "files": [
32
+ "lib",
33
+ "README.md"
34
+ ],
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/mohd-Bilal-exe/native-motion.git"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/mohd-Bilal-exe/native-motion/issues"
41
+ },
42
+ "homepage": "https://github.com/mohd-Bilal-exe/native-motion#readme"
43
+ }