猿问

请问react怎么实现动画暂停/继续?

AnimationPlayState: 'paused'在ios上失效,所以打算弃之,我看到一个大神的解决方法https://codepen.io/HaoyCn/pen...,但是不知道在react上怎么写,求指点!

<div style={this.props.clickonthe ? {

    AnimationPlayState: 'running',

    WebkitAnimationPlayState: 'running',


} : {

        AnimationPlayState: 'paused',

        WebkitAnimationPlayState: 'paused',


    }}>


收到一只叮咚
浏览 756回答 3
3回答

拉丁的传说

知道react的state不?操作它就可以了。

肥皂起泡泡

constructor(props) {&nbsp; super(props);&nbsp; this.state = {&nbsp; &nbsp; isPlay: false&nbsp; };}/*** click function*/playFn(){&nbsp; &nbsp; this.setState({&nbsp; &nbsp; &nbsp; &nbsp; !this.state.isPlay&nbsp; &nbsp; })}render(){&nbsp; &nbsp; return(&nbsp; &nbsp; &nbsp; &nbsp; <div onClick={this.playFn} className={this.state.isPlay?"animation":"noAnimation"}></div>&nbsp; &nbsp; )}
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答