withTimingを使って、円の拡大に『時間』をつける
まずは、withTimingをつけるだけ。
App.js
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, Button } from 'react-native';
import Animated, { useSharedValue, useAnimatedProps, useAnimatedStyle, withTiming} from 'react-native-reanimated';
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
export default function App() {
const r = useSharedValue(20);
const handlePress = () => {
}
return (
<View style={styles.container}>
<AnimatedCircle cx="200" cy="200" fill="blue" animatedProps={animatedProps}/>
<View style={{marginBottom:100}}>
<Button onPress={handlePress} title="PUSH"/>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
次に 1回の拡大時間を1000ミリ秒に設定する
App.js
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, Button } from 'react-native';
import Animated, { useSharedValue, useAnimatedProps, useAnimatedStyle, withTiming} from 'react-native-reanimated';
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
export default function App() {
const r = useSharedValue(20);
const handlePress = () => {
}
return (
<View style={styles.container}>
<AnimatedCircle cx="200" cy="200" fill="blue" animatedProps={animatedProps}/>
<View style={{marginBottom:100}}>
<Button onPress={handlePress} title="PUSH"/>
</View>
</View>
);
}
const styles = StyleSheet.create({
container: {
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
*1:) => ({
}
*2:) => ({
duration:1000,
}),
}