Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

animore

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

animore

Animore makes DOM state transitions easier

  • 1.0.0
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

animore

Animore makes DOM state transitions easier It uses internally the MutationObserver API to determinate whether a DOM node should be transitioned to a different state. 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 automatic transitions

You can pass a query or a DOM node to animore and it will start watching its changes through a MutationObserver to trigger automatically the transitions.


const anima = animore('.my-div')[0] // animore returns always an array!

anima.el.style.marginTop = '300px'
// animore will autimatically detect this change and transition the y position of the `div`

Manual transitions

You can temporary freeze the watcher to trigger manually multiple transitions at same time:


const anima = animore('.my-div')[0]

anima.freeze()
anima.el.style.marginTop = '300px'
anima.el.style.marginLeft = '500px'
anima.unfreze().apply()
// animore will autimatically detect this change and transition the y position of the `div`

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 function will return an object with the following properties

animore.destroy

Remove the DOM events disconnecting the MutationObserver internally created

@returns self

animore.apply

Apply manually an animation comparing the current DOM node state with its previous state

@returns self

animore.freeze

Freeze temporarily all the MutationObserver automatic updates

@returns self

animore.unfreeze

Re enable again the automatic transitions updates

@returns self

animore.el

Reference to the DOM node observed

@returns HTMLElement

FAQs

Package last updated on 08 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc