claude take :(
This commit is contained in:
1 parent
fc12cecd30
commit
73d2c4c1ed
13 files changed
+1460
-517
No files matched your search
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* Reusable Animation Utilities
|
||||
* Pre-configured animations for consistent motion design
|
||||
*/
|
||||
|
||||
import { Animated, Easing } from 'react-native';
|
||||
|
||||
export const animations = {
|
||||
// Fade animations
|
||||
fadeIn: (animatedValue: Animated.Value, duration = 250) => {
|
||||
return Animated.timing(animatedValue, {
|
||||
toValue: 1,
|
||||
duration,
|
||||
easing: Easing.out(Easing.ease),
|
||||
useNativeDriver: true,
|
||||
});
|
||||
},
|
||||
|
||||
fadeOut: (animatedValue: Animated.Value, duration = 250) => {
|
||||
return Animated.timing(animatedValue, {
|
||||
toValue: 0,
|
||||
duration,
|
||||
easing: Easing.in(Easing.ease),
|
||||
useNativeDriver: true,
|
||||
});
|
||||
},
|
||||
|
||||
// Scale animations
|
||||
scaleIn: (animatedValue: Animated.Value, duration = 250) => {
|
||||
return Animated.spring(animatedValue, {
|
||||
toValue: 1,
|
||||
friction: 8,
|
||||
tension: 40,
|
||||
useNativeDriver: true,
|
||||
});
|
||||
},
|
||||
|
||||
scaleOut: (animatedValue: Animated.Value, duration = 200) => {
|
||||
return Animated.timing(animatedValue, {
|
||||
toValue: 0,
|
||||
duration,
|
||||
easing: Easing.in(Easing.ease),
|
||||
useNativeDriver: true,
|
||||
});
|
||||
},
|
||||
|
||||
// Press animation (scale down slightly)
|
||||
pressIn: (animatedValue: Animated.Value) => {
|
||||
return Animated.spring(animatedValue, {
|
||||
toValue: 0.95,
|
||||
friction: 8,
|
||||
tension: 100,
|
||||
useNativeDriver: true,
|
||||
});
|
||||
},
|
||||
|
||||
pressOut: (animatedValue: Animated.Value) => {
|
||||
return Animated.spring(animatedValue, {
|
||||
toValue: 1,
|
||||
friction: 8,
|
||||
tension: 100,
|
||||
useNativeDriver: true,
|
||||
});
|
||||
},
|
||||
|
||||
// Slide animations
|
||||
slideInUp: (animatedValue: Animated.Value, duration = 300) => {
|
||||
return Animated.timing(animatedValue, {
|
||||
toValue: 0,
|
||||
duration,
|
||||
easing: Easing.out(Easing.cubic),
|
||||
useNativeDriver: true,
|
||||
});
|
||||
},
|
||||
|
||||
slideOutDown: (animatedValue: Animated.Value, duration = 250) => {
|
||||
return Animated.timing(animatedValue, {
|
||||
toValue: 100,
|
||||
duration,
|
||||
easing: Easing.in(Easing.cubic),
|
||||
useNativeDriver: true,
|
||||
});
|
||||
},
|
||||
|
||||
// Pulse animation (for FAB or notifications)
|
||||
pulse: (animatedValue: Animated.Value) => {
|
||||
return Animated.sequence([
|
||||
Animated.timing(animatedValue, {
|
||||
toValue: 1.1,
|
||||
duration: 150,
|
||||
easing: Easing.out(Easing.ease),
|
||||
useNativeDriver: true,
|
||||
}),
|
||||
Animated.timing(animatedValue, {
|
||||
toValue: 1,
|
||||
duration: 150,
|
||||
easing: Easing.in(Easing.ease),
|
||||
useNativeDriver: true,
|
||||
}),
|
||||
]);
|
||||
},
|
||||
|
||||
// Stagger animation for lists
|
||||
stagger: (animations: Animated.CompositeAnimation[], delay = 50) => {
|
||||
return Animated.stagger(delay, animations);
|
||||
},
|
||||
|
||||
// Parallel animations
|
||||
parallel: (animations: Animated.CompositeAnimation[]) => {
|
||||
return Animated.parallel(animations);
|
||||
},
|
||||
|
||||
// Sequence animations
|
||||
sequence: (animations: Animated.CompositeAnimation[]) => {
|
||||
return Animated.sequence(animations);
|
||||
},
|
||||
};
|
||||
|
||||
// Spring configurations
|
||||
export const springConfig = {
|
||||
gentle: {
|
||||
friction: 10,
|
||||
tension: 40,
|
||||
},
|
||||
bouncy: {
|
||||
friction: 5,
|
||||
tension: 40,
|
||||
},
|
||||
stiff: {
|
||||
friction: 8,
|
||||
tension: 100,
|
||||
},
|
||||
};
|
||||
|
||||
// Timing configurations
|
||||
export const timingConfig = {
|
||||
fast: {
|
||||
duration: 150,
|
||||
easing: Easing.out(Easing.ease),
|
||||
},
|
||||
normal: {
|
||||
duration: 250,
|
||||
easing: Easing.out(Easing.ease),
|
||||
},
|
||||
slow: {
|
||||
duration: 350,
|
||||
easing: Easing.out(Easing.ease),
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user