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.
- package/LICENSE +20 -21
- package/lib/index.d.ts +53 -19
- package/lib/index.js +401 -272
- 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
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
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 [
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
|
166
|
-
if (shouldExit && !
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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 &&
|
|
216
|
-
|
|
280
|
+
else if (!shouldExit && isExitingRef.current) {
|
|
281
|
+
// Re-entering: reset everything
|
|
282
|
+
isExitingRef.current = false;
|
|
217
283
|
setIsPresent(true);
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
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
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (
|
|
326
|
-
|
|
327
|
-
if (
|
|
328
|
-
|
|
329
|
-
if (
|
|
330
|
-
|
|
331
|
-
if (
|
|
332
|
-
|
|
333
|
-
if (
|
|
334
|
-
|
|
335
|
-
|
|
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.
|
|
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
|
+
}
|