@popp0102/nova 0.3.3 → 0.4.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,48 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import { Animated } from 'react-native';
3
+
4
+ export default function ShakeView({
5
+ shake,
6
+ children,
7
+ style,
8
+ duration = 50,
9
+ distance = 10,
10
+ intensity = 4
11
+ }) {
12
+ const shakeAnim = useRef(new Animated.Value(0)).current;
13
+
14
+ useEffect(() => {
15
+ if (shake) {
16
+ const shakeSequence = [];
17
+
18
+ // Create alternating shake animations based on intensity
19
+ for (let i = 0; i < intensity; i++) {
20
+ const direction = i % 2 === 0 ? distance : -distance;
21
+ shakeSequence.push(
22
+ Animated.timing(shakeAnim, {
23
+ toValue: direction,
24
+ duration,
25
+ useNativeDriver: true
26
+ })
27
+ );
28
+ }
29
+
30
+ // Return to center
31
+ shakeSequence.push(
32
+ Animated.timing(shakeAnim, {
33
+ toValue: 0,
34
+ duration,
35
+ useNativeDriver: true
36
+ })
37
+ );
38
+
39
+ Animated.sequence(shakeSequence).start();
40
+ }
41
+ }, [shake, duration, distance, intensity]);
42
+
43
+ return (
44
+ <Animated.View style={[style, { transform: [{ translateX: shakeAnim }] }]}>
45
+ {children}
46
+ </Animated.View>
47
+ );
48
+ }
package/lib/index.js CHANGED
@@ -3,3 +3,4 @@ export { default as Modal } from './components/Modal';
3
3
  export { default as Badge } from './components/Badge';
4
4
  export { default as FadeView } from './components/animations/FadeView';
5
5
  export { default as SlideView } from './components/animations/SlideView';
6
+ export { default as ShakeView } from './components/animations/ShakeView';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popp0102/nova",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "description": "React Native component library",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",