@popp0102/nova 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Animated } from 'react-native';
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
const DIRECTIONS = {
|
|
5
|
+
IN: 'in',
|
|
6
|
+
OUT: 'out'
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const VALID_DIRECTIONS = Object.values(DIRECTIONS);
|
|
10
|
+
|
|
11
|
+
export default function FadeView({ children, direction = DIRECTIONS.IN, duration = 1000 }) {
|
|
12
|
+
if (!VALID_DIRECTIONS.includes(direction)) {
|
|
13
|
+
throw new Error(`FadeView: direction must be one of ${VALID_DIRECTIONS.join(', ')}. Got: ${direction}`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const fadeAnimationValue = useRef(
|
|
17
|
+
new Animated.Value(direction === DIRECTIONS.IN ? 0 : 1)
|
|
18
|
+
).current;
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
Animated.timing(fadeAnimationValue, {
|
|
22
|
+
toValue: direction === DIRECTIONS.IN ? 1 : 0,
|
|
23
|
+
duration,
|
|
24
|
+
useNativeDriver: true
|
|
25
|
+
}).start();
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Animated.View style={{ opacity: fadeAnimationValue }}>
|
|
30
|
+
{children}
|
|
31
|
+
</Animated.View>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Animated } from 'react-native';
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
const DIRECTIONS = {
|
|
5
|
+
LEFT: 'left',
|
|
6
|
+
RIGHT: 'right',
|
|
7
|
+
UP: 'up',
|
|
8
|
+
DOWN: 'down',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const VALID_DIRECTIONS = Object.values(DIRECTIONS);
|
|
12
|
+
|
|
13
|
+
export default function SlideView({ children, direction = DIRECTIONS.LEFT, duration = 1000 }) {
|
|
14
|
+
if (!VALID_DIRECTIONS.includes(direction)) {
|
|
15
|
+
throw new Error(`SlideView: direction must be one of ${VALID_DIRECTIONS.join(', ')}. Got: ${direction}`);
|
|
16
|
+
}
|
|
17
|
+
let initialValue = 300;
|
|
18
|
+
let transformProperty = 'translateX';
|
|
19
|
+
|
|
20
|
+
switch(direction) {
|
|
21
|
+
case DIRECTIONS.LEFT:
|
|
22
|
+
initialValue = 300;
|
|
23
|
+
transformProperty = 'translateX';
|
|
24
|
+
break;
|
|
25
|
+
case DIRECTIONS.RIGHT:
|
|
26
|
+
initialValue = -300;
|
|
27
|
+
transformProperty = 'translateX';
|
|
28
|
+
break;
|
|
29
|
+
case DIRECTIONS.UP:
|
|
30
|
+
initialValue = 300;
|
|
31
|
+
transformProperty = 'translateY';
|
|
32
|
+
break;
|
|
33
|
+
case DIRECTIONS.DOWN:
|
|
34
|
+
initialValue = -300;
|
|
35
|
+
transformProperty = 'translateY';
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const slideAnimationValue = useRef(new Animated.Value(initialValue)).current;
|
|
40
|
+
|
|
41
|
+
const slideIn = () => {
|
|
42
|
+
Animated.timing(slideAnimationValue, {
|
|
43
|
+
toValue: 0,
|
|
44
|
+
duration: duration,
|
|
45
|
+
useNativeDriver: true,
|
|
46
|
+
}).start();
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
slideIn();
|
|
51
|
+
}, []);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Animated.View style={{ transform: [{ [transformProperty]: slideAnimationValue }] }}>
|
|
55
|
+
{children}
|
|
56
|
+
</Animated.View>
|
|
57
|
+
);
|
|
58
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@popp0102/nova",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "React Native component library",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"prepublishOnly": "npm run lint && npm run test"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
+
"@expo/vector-icons": ">=14.0.0",
|
|
33
34
|
"react": ">=18.0.0",
|
|
34
35
|
"react-native": ">=0.70.0",
|
|
35
|
-
"react-native-safe-area-context": ">=4.0.0"
|
|
36
|
-
"@expo/vector-icons": ">=14.0.0"
|
|
36
|
+
"react-native-safe-area-context": ">=4.0.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@babel/core": "^7.24.0",
|
|
@@ -49,7 +49,5 @@
|
|
|
49
49
|
"react": "^18.3.1",
|
|
50
50
|
"react-native": "^0.75.0",
|
|
51
51
|
"react-test-renderer": "^18.3.1"
|
|
52
|
-
},
|
|
53
|
-
"dependencies": {
|
|
54
52
|
}
|
|
55
53
|
}
|