JSPM

  • Created
  • Published
  • Downloads 495776
  • Score
    100M100P100Q239015F
  • License Apache-2.0

react simple animate

Package Exports

  • react-simple-animate

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-simple-animate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

React Simple Animate

npm version npm downloads npm npm

Make web animation simple 👏

Features:

  • Simple animation from inline style A to style B
  • Support will mount and unmount (New)
  • Make animation toggle easy
  • In-built delay animation mechanism
  • Tiny size without other dependency

Install

$ yarn add react-simple-animate
or
$ npm install react-simple-animate -S

Example

Check out the interactive demo. 😍

Navigate into example folder and install

$ yarn && yarn start
or
$ npm install && npm run start

Screenshot of the example app below

Screenshots

Quick start

The following example demonstrate animate individual or array of components. React simple animate will take cares component will mount and unmount.

import react from 'react';
import Animate from 'react-simple-animate';
import YourComponent from './YourComponent';

const startStyle = { opacity: 0 };
const endStyle = { opacity: 1 };

// individual component animation
export const SexyComponent(props) => 
    <Animate durationSeconds={0.2}
         startAnimation
         {  ...{ startStyle endStyle } }
       >
        <YourComponent>
    </Animate>;

// array of components with add or remove will trigger animation
export function SexyComponents(props) => 
    <Animate durationSeconds={0.2}
         startAnimation
         animateOnAddRemoveChildren
         {  ...{ startStyle endStyle } }
       >
        {props.componentsArray.map((key) => <YourComponent key={key}>}
    </Animate>;

API

Prop Type Required Description
startAnimation boolean Defaults to false. Set to true to start the animation.
children node Child component to be animated.
startStyle string Component initial inline style.
endStyle string Component transition to inline style.
tag string Default tag is div, this allow custom tag to be wrap around.
animateOnAddRemoveChildren boolean Enable support for will mount and unmount.
onCompleteStyle string Style to be applied after the animation is completed.
durationSeconds number How long the animation takes in seconds, same apply to mount and unmount.
delaySeconds number How much delay should apply before animation starts.
reverseDelaySeconds number How much delay should apply when reverse/toggle animation.
onComplete function Call back function after animation complete.
onError function Call back function after component error (React 16 only).
easeType string Easing type refer to http://easings.net/
className string To specify a CSS class.
forceUpdate boolean Force component to re-render.