0
1996年に私はクライアントのためにスピニングロゴを作成しました.2017年には、Animatedのおかげで戻ってきました。Animated.loop image
<hr />
以下のコードは機能しますが、再起動すると小さなバンプがあります。
Animated.loop
はどのように使用できますか?それは終わりに達するたびに«がリセットされ、開始から再び始まります»。
Animated.loop(
Animated.timing(this.state.spinValue, {
toValue: 1,
duration: this.props.duration,
easing: Easing.linear,
useNativeDriver: true
})
).start();
static defaultProps = {
duration: 60/(33 + 1/3) * 1000
}
constructor (props) {
super(props);
this.state = {
spinValue: new Animated.Value(0)
};
}
componentDidMount() {
this._animate();
}
_animate() {
Animated.timing(this.state.spinValue, {
toValue: 1,
duration: this.props.duration,
easing: Easing.linear,
useNativeDriver: true
}).start(event => {
if (event.finished) {
this.setState({
spinValue: new Animated.Value(0)
}, this._animate.bind(this));
}
});
}
render() {
const spin = this.state.spinValue.interpolate({
inputRange: [0, 1],
outputRange: ['0deg', '360deg']
});
return (
<View style={ Loading.style.container }>
<Animated.Image
source={ logo }
style={{ transform: [{ rotate: spin }] }}
/>
</View>
);
}
をそのライブラリは 'Animated.sequence'を使用しているようです。私は純粋なReact Nativeに固執したいと思います。 – webjay