1.3.0 • Published 6 years ago

react-animate-x v1.3.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

React Animate X

A React implimentation of Animate X, a super small animation library for animating components, numbers, objects, and arrays.

Installation

With npm:

npm install --save react-animate-x

Or with Yarn:

yarn add react-animate-x

Usage

Simple

import Animate from 'react-animate-x'

...

<Animate from={0}, to={100}>
   {state => (
      <div style={{ transform: `translateX(${state}px)` }}>Animating!</div>
   )}
</Animate>

Easing

The simplest way to apply easing to your animation is with the eases module, but any easing function will work.

import Animate from 'react-animate-x'
import { bounceOut } from 'eases'

...

<Animate
   from={{
      x: 0,
      y: 0,
   }}
   to={{
      x: 100,
      y: 150,
   }}
   easing={bounceOut}>
   {({ x, y }) => (
      <div style={{ transform: `translate(${x}px, ${y}px)` }}>Animating!</div>
   )}
</Animate>

Props

PropDescriptionDefault
fromA number, object, or array to start tweening from0
toA number, object, or array to tween to (must match schema of "from")100
durationThe number of milliseconds the animation should last1000
easingAn easing function for the animationfunction(time){ return time }
loopAdd this prop to loop the animation infinitelyfalse
onStartA function that will be called every time the animation startsn/a
onEndA function that will be called every time the animation endsn/a
animatingSet to false to stop the animationn/a