Files
OrionTV/hooks/useButtonAnimation.ts

18 lines
451 B
TypeScript

import { useRef, useEffect } from 'react';
import { Animated } from 'react-native';
export const useButtonAnimation = (isFocused: boolean) => {
const scaleValue = useRef(new Animated.Value(1)).current;
useEffect(() => {
Animated.spring(scaleValue, {
toValue: isFocused ? 1.1 : 1,
friction: 5,
useNativeDriver: true,
}).start();
}, [ isFocused, scaleValue]);
return {
transform: [{ scale: scaleValue }],
};
};