Looping animation for react-motion Spring
Demo
https://nkbt.github.io/react-motion-loop
Codepen demo
https://codepen.io/nkbt/pen/ybqmWw
Installation
NPM
npm install --save react-motion-loop
yarn
yarn add react-motion-loop
1998 Script Tag:
(Module exposed as `ReactMotionLoop`)
Usage
;;;; const App = <div> <h1>Looping animation</h1> <ReactMotionLoop styleFrom=width: height: styleTo=width: height: > <div style=style /> </ReactMotionLoop> <h1>Pulsing animation</h1> <ReactMotionLoop styleFrom=width: 0 height: 0 // Instantly jump to the initial style styleTo=width: height: > <div style=style /> </ReactMotionLoop> </div>; const appRoot = document;documentbody;ReactDOM;
Options
styleFrom
: PropTypes.object.isRequired
Initial style for animated element, used for ReactMotion's defaultStyle
and as returning animation
styleTo
: PropTypes.object.isRequired
Element is animated to this style, used for ReactMotion's style
<Motion>
as is
All arbitrary props will be transferred to WARN: passing onRest
, style
or defaultStyle
will override looping behavior, since internally Motion
is used like:
<Motion defaultStyle=defaultStyle onRest=thisonRest style=style ...props />
Development and testing
Currently is being developed and tested with the latest stable Node
on OSX
.
To run example covering all ReactMotionLoop
features, use yarn start
, which will compile example/index.js
git clone git@github.com:nkbt/react-motion-loop.gitcd react-motion-loopyarn installyarn start # then open http://localhost:8080
Tests
# to run ESLint check yarn lint # to run tests yarn test
License
MIT