Move it
Description
Javascript animation and transition utility. Uses CSS under the hood. Useful for React performant animations.
Features
- Supports animations and transitions with the same API
- Animations/transitions definitions are in plain javascript. This means you can create functions that create animations.
- Cleans up everything on completion
- Automatically prefixed
- Supports only setting
from
orto
Installation
npm i --save moveit
Demo
npm start
then visit http://127.0.0.1:3000
Usage
;
definition
is an object with keyframes
and standard CSS properties for
animation / transition. keyframes
takes percentages (or from
and to
) as
keys and CSS maps as values.
Possible properties :
delay
duration
ease
Animation only :
iterationCount
direction
fillMode
Easing
You can pass a string corresponding to one of these easings, or use a custom function using CSS cubic-bezier()
syntax.
Example
; const definition = keyframes: from: opacity: '0' to: opacity: '1' ease: 'ease-in' duration: '1s'; ;
You can use transition or animation
API is the same, but with animation you can add intermediate keyframes.
; const definition = keyframes: from: opacity: '0' '50%': opacity: '.3' to: opacity: '1' ease: 'ease-in' duration: '1s'; ;
Callback on end
;
Override definition
const override = ease: 'ease-out'; ;
With React
// You could import this from an animations.js file, pass it through props...const openMenu = { return keyframes: to: transform: `translate3d(px, 0, 0)` ease: 'ease-out-cubic' duration: '1s' ;}; { ; } { return <div ref='animated'> <button onClick= ::thishandleClick ></button> </div> ; }