我可以在 React 组件中使用 velocity.js 动画而不集成它吗?没有 velocity-react 库吗? 默认情况下,我不喜欢这样,当安装组件时,会显示动画的最终状态。如何使动画在组件加载时运行?
最佳答案
简单示例:
导入速度
import Velocity from 'velocity-animate';
然后在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>; } }
关于javascript - 在 React 中使用 velocity.js 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39290835/