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

ani-machine

v0.1.11

Published

Declarative animation and machine state

Downloads

2

Readme

AniMachine

Declarative Animation and Simple Machine State.

  • 4.5KB minified and Gzipped

→ Demo ←

Optional Dependencies

How to start

Add JS dependency

<script src="../ani-machine.min.js"></script>

At the end of DOM

<script>am.start();</script>

Enter Animation

enter!

Add data-am attribute on DOM element with ":enter" special keyword

<div data-am=":enter left move 500px over 1.0s">HelloWorld</div>

State

state

default state is declare with data-am

<div class="element"
	data-am=":on enter :animate pulse
			 :on leave :animate tada">
</div>

Here we define animation on mouseenter and mouseleave

If you want to declare a next state

<div class="element"
	data-am=""
	data-am-next=":on enter :animate bounce">
</div>

How to change state ?

changestate!

You need to use ":go" keyword followed by state name to change state when played animation is finished

<div class="element"
	data-am=":enter left move 500px :go next"
	data-am-next=":on enter :animate pulse
				  :on leave :animate tada">
</div>

How to launch CSS Animation ?

Add ":animate" keyword followed by animation CSS class name

<div class="element"
	data-am=":animate tada">
</div>

Here we use animate.css class name, but it might be another css class

To chain CSS animation

<div class="element"
	data-am=":animate tada pulse">
</div>

How to launch CSShake Animation ?

shake!

Add ":shake" followed by csshake animation name you want to apply

<div class="element"
	data-am=":shake slow">
</div>

How to trigger animation ?

trigger!

Use ":trigger" keyword

<div class="element"
	data-am-special=":animate bounce
					 :trigger .btn--trigger click">
</div>
<div class=".btn--trigger"></div>

You can use default event

  • click (click event)
  • enter (mouseenter event)
  • leave (mouseleave event)
  • ...

Autostart

By default, all DOM element with data-am attribute will be in default state

Reveal Animation

Special state name are use to specify animations you want to play when element is entering or leaving the viewport.

You can trigger animation with state enter

<div class="element"
	data-am-enter=":enter left move 500px">
</div>

or state leave

<div class="element"
	data-am-leave=":animate bounceOutRight">
</div>

Before and After Callbacks

You can bind ":before" or ":after" callback animation event

<div class="element"
	data-am-enter=":before beforeFn() :enter left move 500px :after afterFn()">
</div>
<script>
function beforeFn(element) {
	console('before callback');
}
function afterFn(element) {
	console('after callback');
}
</script>

element is DOM element which call the callback

How to add a pause ?

You can use ":wait" to make a pause before running animation or after

<div class="element"
	data-am-enter=":wait 0.2s :animate pulse">
</div>

Release History

  • v0.1.9:
    • add :wait operator
    • add element as first parameter in before and after callbacks
    • remove some old browser compatibility codes
  • v0.1.8: remove all dependencies
  • v0.1.7: initial revision working with AngularJS

Browser Support

  • IE10+
  • Chrome4+
  • Safari8+
  • FF5+
  • Opera12+

License

Copyright (c) 2017 John Fischer Licensed under the MIT license.