mirror of
https://github.com/zimplexing/OrionTV.git
synced 2026-02-04 03:36:29 +08:00
18 lines
478 B
TypeScript
18 lines
478 B
TypeScript
import { useRef, useEffect } from 'react';
|
|
import { Animated } from 'react-native';
|
|
|
|
export const useButtonAnimation = (isFocused: boolean, size: number = 1.1) => {
|
|
const scaleValue = useRef(new Animated.Value(1)).current;
|
|
|
|
useEffect(() => {
|
|
Animated.spring(scaleValue, {
|
|
toValue: isFocused ? size : 1,
|
|
friction: 5,
|
|
useNativeDriver: true,
|
|
}).start();
|
|
}, [ isFocused, scaleValue, size]);
|
|
|
|
return {
|
|
transform: [{ scale: scaleValue }],
|
|
};
|
|
}; |