velocity.js 动画在 React 中的使用

Usage of velocity.js animations in React

我可以在 React 组件中使用 velocity.js 动画而不集成它吗?没有 velocity-react图书馆? 默认情况下,我不喜欢这样,当安装组件时,会显示动画的最终状态。如何在组件加载时制作 运行 的动画?

简单例子:

  1. 导入速度

    import Velocity from 'velocity-animate';
    
  2. 然后在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>;
        }
    }