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

@exah/promise-animejs

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exah/promise-animejs

Simple wrapper around Anime.js, that resolves Promise when animation is complete

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Promise + Anime.js

Simple wrapper around Anime.js, that resolves Promise when animation is complete.

Install

Note: this package include animejs as peer dependency, so you must install it manually

$ npm install -S animejs @exah/promise-animejs

Why?

It can help chain animation, i.e. animate multiple dom nodes in order:

import promiseAnime from '@exah/promise-animejs'

const $nodes = document.querySelectorAll('.class-to-animate')

const animations = Array.from($nodes).reduce(
  (promise, $el) => promise.then(() => 
    promiseAnime({
      targets: $el,
      opacity: [0, 1],
      easing: 'easeOutCirc'
    })
  ),
  Promise.resolve()
)

/* All animations is finished */
animations
  .then(() => console.log('complete'))

Usage

API

promiseAnime(
  { /* anime options */ }, 
  function (animation) { /* control animation */ }
)
.then(animation => /* animation complete */)

Example

Simply pass Anime.js options to promiseAnime function.

// before
anime({
  targets: 'div',
  opacity: [0, 1],
  easing: 'easeOutCirc',
  complete(animation) {
    console.log('complete')
  }
})

// after
promiseAnime({
  targets: 'div',
  opacity: [0, 1],
  easing: 'easeOutCirc'
})
.then(animation => console.log('complete'))

Since wrapper returns Promise, to access animation instance simply pass handler as second argument.

promiseAnime({ /* options */ }, animation => {
  animation.pause() // pause animation
})
.then(animation => console.log('complete'))

MIT License. © 2017 John Grishin.

FAQs

Package last updated on 28 Jan 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