Да, я тоже думал через scale сделать, а как добавить плавность? Типо аналог transition есть в rn?
import React, { useState } from "react";
import {
TouchableOpacity,
Animated,
Easing
} from "react-native";
() => {
const [animatedValue] = useState(new Animated.Value(0));
const animStart = () => {
Animated.timing(animatedValue, {
toValue: 1,
duration: 100,
easing: Easing.ease,
useNativeDriver: false
}).start();
};
const animEnd = () => {
Animated.timing(animatedValue, {
toValue: 0,
duration: 100,
easing: Easing.ease,
useNativeDriver: false
}).start();
};
const scale = animatedValue.interpolate({
inputRange: [0, 1],
outputRange: [1, 0.95]
});
return (
<Animated.View
style={{
transform: [{ scale }]
}}
>
<TouchableOpacity
onPress={() => {}}
activeOpacity={0.95}
onLongPress={animStart}
onPressOut={animEnd}
>
</TouchableOpacity>
</Animated.View>
);
)
}