Socket
Socket
Sign inDemoInstall

animotion

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    animotion

Subscribe to element animation events in a declarative way


Version published
Weekly downloads
5
increased by66.67%
Maintainers
1
Install size
5.44 kB
Created
Weekly downloads
 

Readme

Source

#Animotion

Subscribe to element animation events in a declarative way DEMO

##Usage

Having the following CSS

#animated-div{
  border: 1px solid;
  width: 1px;
  height: 1px;
  animation: foo 2s infinite;
}

@keyframes foo {
  0%{
    transform: translateX(0);
  }
  50%{
    transform: translateX(5px);
  }
  100% {
    transform: translateX(0);
  }
}

###Listen for events

const animotion = require('animotion');
const div = document.getElementById('animated-div');

let iterationCount;

const start = _ => {console.log(`Element started animation at ${new Date()}`)};
const iteration = _ => {console.log(`Element iteration: ${iterationCount++}`)};
const end = _ => {console.log(`Element finished animation at ${new Date()}`)};

animotion(div)
  .on('start', start)
  .on('iteration', iteration)
  .on('end', end)

###Filter by animation name This could be useful if you add/remove classes that involve animations in the same element and you want to react different to them:

//The start event will not be called because the animation name is different
animotion(div)
  .name('bar')
  .on('start', start)

//Events are called because the animation name matches
animotion(div)
  .name('foo')
  .on('start', start)
  .on('end', end)

###Demo Tracking animation status, slapsed time and iteration number with Animotion

https://zzarcon.github.io/animotion/

###Installation

$ npm i animotion -S

###Author

@zzarcon :rocket:

FAQs

Last updated on 05 Aug 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc