Ivi*_*dic 1 javascript animation reactjs velocity.js
我可以在React组件中使用velocity.js动画而无需在没有速度反应库的情况下进行集成吗?我不喜欢默认情况下,当安装组件时,会显示动画的最终状态.如何让动画在组件加载上运行?
简单的例子:
进口速度
import Velocity from 'velocity-animate';
Run Code Online (Sandbox Code Playgroud)然后在componentDidMount中开始动画
import React, { Component } from 'react';
class VelocityExample extends Component {
componentDidMount(){
Velocity(this.refs.block,{ scale: 2 },500)
.then(e=>console.log('animation complete'))
}
render(){
return <div ref="block" >VelocityExample</div>;
}
}
Run Code Online (Sandbox Code Playgroud)