1.6.9 • Published 6 years ago

react-animatronics v1.6.9

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

react-animatronics

Declarative, coordinated animations for React components.

build status npm version license

Table of Contents

Installation

# npm
npm install --save react-animatronics

# yarn
yarn add react-animatronics

Quick Intro

React-animatronics allows you to declare complex animations involving multiple React components throughout your component hierarchy.

Here's a quick example demonstrating some of what react-animatronics can do:

import React from 'react'
import { Animatronics, Control } from 'react-animatronics'

const Square = ({ style, animatronicStyles }) => (
  <div
    style={{
      height: '100px',
      width: '100px',
      cursor: 'pointer',
      position: 'absolute',
      ...style,
      ...animatronicStyles
    }}
  />
);

const SquareOne = () => (
  <Control name='squareOne'>{
    ({ animatronicStyles }) => (
      <Square
        style={{
          backgroundColor: 'blue',
          top: '0px',
          left: '0px'
        }}
        animatronicStyles={ animatronicStyles }
      />
    )
  }</Control>
);

const SquareTwo = () => (
  <Control name='squareTwo'>{
    ({ animatronicStyles }) => (
      <Square
        style={{
          backgroundColor: 'red',
          top: '200px',
          left: '0px'
        }}
        animatronicStyles={ animatronicStyles }
      />
    )
  }</Control>
);

const SquareThree = () => (
  <Control name='squareThree'>{
    ({ animatronicStyles }) => (
      <Square
        style={{
          backgroundColor: 'green',
          top: '0px',
          left: '200px'
        }}
        animatronicStyles={ animatronicStyles }
      />
    )
  }</Control>
);

const animations = () => [
  {
    squareOne: {
      duration: 500,
      from: {
        top: '0px',
        left: '0px'
      },
      to: {
        top: '200px',
        left: '200px'
      }
    },
    squareTwo: {
      duration: 500,
      from: {
        top: '200px',
        left: '0px'
      },
      to: {
        top: '0px',
        left: '0px'
      }
    },
  },
  {
    squareOne: {
      duration: 500,
      from: {
        top: '200px',
        left: '200px'
      },
      to: {
        top: '0px',
        left: '200px'
      }
    },
    squareThree: {
      duration: 500,
      from: {
        top: '0px',
        left: '200px'
      },
      to: {
        top: '200px',
        left: '0px'
      }
    }
  }
];

const App = () => (
  <Animatronics animations={ animations }>{
    ({ playAnimation, reset }) => (
      <div
        style={{ cursor: 'pointer' }}
        onClick={() => {
          playAnimation(() => {
            setTimeout(reset, 500);
          });
        }}
      >
        <SquareOne />
        <SquareTwo />
        <SquareThree />
      </div>
    )
  }</Animatronics>

);

Live CodeSandbox example: https://codesandbox.io/s/wq39rlvnk7

Documentation

  • Walkthrough - for those new to react-animatronics
  • API Reference - for those that just need to remember how to do "that one thing"
1.6.9

6 years ago

1.6.8

6 years ago

1.6.7

6 years ago

1.6.6

6 years ago

1.6.5

6 years ago

1.6.4

6 years ago

1.6.3

6 years ago

1.6.2

6 years ago

1.6.2-beta.1

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.6.0-beta.4

6 years ago

1.6.0-beta.3

6 years ago

1.6.0-beta.2

6 years ago

1.6.0-beta.1

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.2.0-alpha.2

6 years ago

1.2.0-alpha.1

6 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.0.1-alpha.9

7 years ago

0.0.1-alpha.8

7 years ago

0.0.1-alpha.7

7 years ago

0.0.1-alpha.6

7 years ago

0.0.1-alpha.5

7 years ago

0.0.1-alpha.4

7 years ago

0.0.1-alpha.3

7 years ago

0.0.1-alpha.2

7 years ago

0.0.1-alpha.1

7 years ago

0.0.1

7 years ago

0.0.0-alpha

7 years ago

0.0.0

7 years ago