react-native animate 动画如何控制停止呢?

export default class  extends Component {
    constructor(props) {
        super(props)
        this.state = {
            value: new Animated.Value(0)
        }
    }
    componentDidMount() {
        this.AnimateRotate()
    }

    AnimateRotate() {
        this.state.value.setValue(0)
        Animated.timing(this.state.value, {
            toValue: 1,
            duration: 15000,
            easing:Easing.out(Easing.linear)
        }).start(() => {
            this.AnimateRotate()
        })
    }
    render() {
        const animateRotate = this.state.value.interpolate({
            inputRange: [0, 1],
            outputRange: ['0deg', '360deg']
        })
        return (
            <View style ={{justifyContent: 'center', alignItems: 'center'}}>
                <Animated.Image style ={[{transform: [{rotateZ: animateRotate}]},this.props.style]} source={this.props.imageSrc}  >
                </Animated.Image>
            </View>
        )
    }
}

上方代码是一个循环旋转的图片,怎么控制它的停止呢,

阅读 5.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进