Refactor button animation logic to focus only on isFocused state and update version to 1.1.0

This commit is contained in:
zimplexing
2025-07-08 20:33:06 +08:00
parent 74ad0872cb
commit b238ffe3ba
4 changed files with 64 additions and 28 deletions

View File

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