npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

actuatejs

v1.0.2

Published

One line easy actuation of CSS animation sequences.

Downloads

19

Readme

Actuate

ac·tu·ate /ˈak(t)SHəˌwāt/ : cause (a machine or device) to operate.

A shiny new (~500b) vanilla implementation of what was previously A tiny jQuery wrapper for animate.css which allows for one line easy actuation of CSS animation sequences with thenable chaining.

Check out this example on CodePen.

Actuate Banner

Getting Started

Note: this library uses promises for which you might need a polyfill

Include the library

Directly in the head of your document from the CDN

<script src='https://unpkg.com/actuatejs'></script>

or require it in your source files after npm install actuatejs

import Actuate from 'actuatejs' // ES6

Define a CSS animation

You can define your own or employ a library like animate.css

@keyframes pulse {
  from { transform: scale(1) }
  50% { transform: scale(1.05) }
  to { transform: scale(1) }
}
.pulse {
  animation-name: pulse;
}

Run with javascript

In a script tag before the closing body tag

Actuate('pulse')(document.body)
.then($ => console.log('Finished animating', $))
.catch($ => console.log($, 'was already animating'))

Usage

The API is intended to be as simple as possible providing low overhead syntax for animation sequencing, chaining of sequences and animationEnd detection.

Single Animation

To animate an HTML element, first pass the Actuate function the name of the CSS animation you would like to apply. This primes the animation ready to be bound to a target element (in this case document.body) which is passed as the second argument:

Actuate('tada')(document.body)

Once the function has received both arguments, the animation will initiate. You can pass in any single HTML element as the target element. For example using the native querySelector method:

Actuate('tada')(document.querySelector('.class'))
Actuate('tada')(document.querySelector('#id'))
Actuate('tada')(document.querySelector('input[type=text]'))

Sequential Animations

Often it is desirable to run animations one after another. There is no native method that assists this behavior. The Actuate function accepts a space delimited list of named CSS animations as the first argument and handles this complexity for you:

Actuate('rollIn tada rollOut')(document.body)

You can also pass in an array of named animations if you prefer:

Actuate(['rollIn', 'tada', 'rollOut'])(document.body)

When one animation finishes the next one will start until there are no more to apply.

Animation End

The Actuate function returns a promise which means you can easily declare a then function which is guaranteed to execute once all the animations in a sequence have been applied.

Actuate('tada fadeOut')(document.body)
.then($ => console.log('Finished Animating', $))

The then function gets passed the target element. In the above case $ === document.body.

Already Animating

The only time Actuate will throw an error is if you try animate an element that is already animating:

addEventListener('click', () =>
  Actuate('tada')(document.body)
  .then($ => console.log('Finished'))
  .catch($ => console.log('Already Animating'))
)

Chaining sequences

The Actuate function takes advantage of partial appliction which means that animation sequences can be defined without having to immediately specify a target element.

var intro = Actuate('rollIn')
var showoff = Actuate('bounce tada bounce')
var outro = Actuate('rollOut')

You can then provide a target element and let it flow through a chain of predefined animation sequences:

Promise.resolve(document.body)
.then(intro)
.then(showoff)
.then(outro)