【发布时间】:2017-11-18 10:23:36
【问题描述】:
我正在使用带有 React 的 animate.css 库,并尝试设置一个元素(按钮)以在悬停时发出脉冲。试图通过文档和这里查看,但找不到完成这个简单任务的方法。如果有人实现了这一点或找到了参考,将不胜感激。
class App extends Component {
constructor(props) {
super(props);
this.handleHover = this.handleHover.bind(this);
}
handleHover(){
this.setState({
isHovered: !this.state.isHovered
});
}
render() {
const btnClass = this.state.isHovered ? "pulse animated" : "";
return (
<div>
<button className={btnClass} onMouseEnter={this.state.handleHover} onMouseLeave={this.state.handleHover}>Test</button>
</div>
);
}
}
export default App;
【问题讨论】:
标签: javascript reactjs events dom-events animate.css