All Projects → lukejacksonn → Actuate

lukejacksonn / Actuate

Licence: MIT License
One line easy actuation of CSS animation sequences

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Actuate

Jstransformer
Normalize the API of any JSTransformer.
Stars: ✭ 139 (+230.95%)
Mutual labels:  promise, transform
react-awesome-reveal
React components to add reveal animations using the Intersection Observer API and CSS Animations.
Stars: ✭ 564 (+1242.86%)
Mutual labels:  css-animations
spatialmath-matlab
Create, manipulate and convert representations of position and orientation in 2D or 3D using Python
Stars: ✭ 142 (+238.1%)
Mutual labels:  transform
promise
A step by step implementation practice of Promise class
Stars: ✭ 31 (-26.19%)
Mutual labels:  promise
vov
✨ vov.css animations for shiny
Stars: ✭ 23 (-45.24%)
Mutual labels:  css-animations
popyt
A very easy to use Youtube Data v3 API wrapper.
Stars: ✭ 42 (+0%)
Mutual labels:  promise
hotscript
HotScript - Revolutionizing how Windows works.
Stars: ✭ 29 (-30.95%)
Mutual labels:  transform
smoothr
A custom React router that leverages the Web Animations API and CSS animations.
Stars: ✭ 28 (-33.33%)
Mutual labels:  css-animations
nglp-angular-material-landing-page
NGLP is an Angular Material Landing Page.
Stars: ✭ 32 (-23.81%)
Mutual labels:  css-animations
Eventually
A Swift Future/Promise library that can be used to model and transform asynchronous results
Stars: ✭ 19 (-54.76%)
Mutual labels:  promise
fuze
A simple CSS Gradient Animator tool built with Vue and Vuex.
Stars: ✭ 71 (+69.05%)
Mutual labels:  css-animations
event-worker
A simpler way of dealing with Web Workers
Stars: ✭ 18 (-57.14%)
Mutual labels:  promise
fastener
Functional Zipper for manipulating JSON
Stars: ✭ 54 (+28.57%)
Mutual labels:  transform
promise
Common interface for simple asynchronous placeholders.
Stars: ✭ 66 (+57.14%)
Mutual labels:  promise
redis-memolock
Redis MemoLock - Distributed Caching with Promises
Stars: ✭ 63 (+50%)
Mutual labels:  promise
Promise
Asynchronous Programming with Promises
Stars: ✭ 15 (-64.29%)
Mutual labels:  promise
web-animation-club
CSS controlled animations with transitionEnd, onTransitionEnd, animationend, onAnimationEnd events and frame throwing. Tiny javascript library with cross-browser methods to handle css animation/transition callbacks and event loop frame throwing. 📚🖥️📱
Stars: ✭ 52 (+23.81%)
Mutual labels:  css-animations
swear
🙏 Flexible promise handling with Javascript
Stars: ✭ 56 (+33.33%)
Mutual labels:  promise
MERN-BUS-APP
This is a MFRP (My first Real Project) assigned to me during my internship at Cognizant. Made with MERN Stack technology.
Stars: ✭ 92 (+119.05%)
Mutual labels:  css-animations
arraync
Async Array methods polyfills
Stars: ✭ 16 (-61.9%)
Mutual labels:  promise

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)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].