2.0.3 • Published 6 years ago

animore v2.0.3

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

animore

Animore makes DOM state transitions easier It uses internally the css transitions to animate 2 different states of the same DOM node. It was inspired by riot-animore and works thanks to the flip technique by Paul Lewis

Build Status NPM version NPM downloads MIT License

Demos

Installation

Via npm

$ npm i animore -S

Script import

Via <script>

<script src="path/to/animore.js"></script>

Via ES2015 modules

import animore from 'animore'

Via commonjs

const animore = require('animore')

Usage

Simple transitions

You can pass a query or a DOM node to animore in the following way:

const animaQuery = animore('.my-div')[0] // animore returns always an array!
const animaNode = animore(myDiv)[0] // DOM nodes are also valid
const animaList = animore([myDiv, myUl]) // an arrays are also valid
const animaNodeList = animore(myUl.children) // NodeLists are valid as well

Remeber to use stash and apply to create your transitions

const anima = animore('.my-div')[0]
anima.stash() // store the previous DOM position
anima.el.style.marginTop = '300px'
anima.apply() // apply the transition

Options

The animore factory function accepts 2 arguments animore(el, options) with the options object you can specify how your animations should behave:

animore(myDiv, {
  duration: 300, // animation duration in ms
  easing: 'ease-in-out', // this should be a valid css easing function
  delay: 20, // animation delay
  onStart: function() { console.log('new animation started ')},
  onCancel: function() { console.log('animation canceled ')},
  onEnd: function() { console.log('animation ended ')}
})

API

Any animore call will return an object with the following properties

animore.stash

Store the current DOM node position and size

@returns self

animore.apply

Apply the transition comparing the current DOM node state with its previous state (it can be called only after a stash)

@returns self

animore.el

Reference to the DOM node queried

@returns HTMLElement

2.0.3

6 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.0

7 years ago

0.0.0

7 years ago