Effortless Micro-Interactions.

A lightweight JavaScript library to add complex animations to your website with zero JavaScript required for basic use. Just add HTML attributes.

Get Started

Why Animasis.js?

All the features you need for delightful interactions.

Zero JavaScript

Add animations directly in your HTML for most use cases. It's plug-and-play.

👆

Trigger-Based

Animate on user actions like `hover`, `click`, `scroll`, or on page `load`.

🎨

Highly Customizable

Easily control duration, easing, delay, and target elements via attributes.

⚡️

Lightweight & Fast

No dependencies and a tiny footprint ensures your site stays performant.

Incredibly Simple Syntax

The core syntax is `trigger:animation | duration | easing | delay`. That's it.

<button data-animasis="hover:pulse | 500ms | ease-out | 100ms">
  Hover Me!
</button>

A Glimpse of the Library

See a fraction of what Animasis.js can do. Interact with the elements below.

1. Attention Seekers

<button data-animasis="hover:shake-x">Shake</button>
<button data-animasis="hover:jello">Jello</button>
<button data-animasis="hover:wobble">Wobble</button>
<button data-animasis="hover:heart-beat">Heart Beat</button>

2. Scroll-Triggered Entrances

These elements animated as you scrolled.

Bounce In Up
Flip In X
Zoom In Left
Jack In The Box
<div data-animasis="scroll:bounce-in-up">...</div>
<div data-animasis="scroll:flip-in-x | 1s | 200ms">...</div>
<div data-animasis="scroll:zoom-in-left | 800ms | 400ms">...</div>
<div data-animasis="scroll:jack-in-the-box | 1s | 600ms">...</div>

3. Click-Triggered Exits

Hinge
Bounce Out
Flip Out Y
Zoom Out Right
<div data-animasis="click:hinge | 2s">...</div>
<div data-animasis="click:bounce-out">...</div>
<div data-animasis="click:flip-out-y">...</div>
<div data-animasis="click:zoom-out-right">...</div>

4. Targeting Other Elements

<button 
  data-animasis="hover:pulse" 
  data-animasis-target="#my-image">
  Hover Me
</button>

<div id="my-image"></div>

Documentation

A comprehensive guide to all the attributes and options available in Animasis.js.

Core Syntax: `data-animasis`

The main attribute that powers the library. The value is a string with one or more instructions, separated by semicolons (`;`). Each instruction follows this pattern:

trigger:animation | duration | easing | delay

Global Attributes

These attributes control behavior for an element's animations.

AttributeDescription
data-animasis-target A CSS selector for an element to animate instead of this one.
data-animasis-once For `scroll` triggers. Set to `false` to replay the animation every time the element enters the viewport. Defaults to `true`.
data-animasis-duration Sets a default duration for all animations on this element (e.g., `500ms`).
data-animasis-easing Sets a default easing function (e.g., `ease-in-out`).
data-animasis-delay Sets a default delay (e.g., `100ms`).

Pre-defined Animations

A massive library of ready-to-use animations. Most have a default duration of 300ms.

AnimationDescription
Attention Seekers
bounceBounces the element up and down.
flashFlashes the element by changing opacity.
pulseGently scales the element up and down.
rubber-bandStretches the element like a rubber band.
shake-xShakes the element horizontally.
shake-yShakes the element vertically.
head-shakeA more subtle, side-to-side head shaking motion.
swingSwings the element back and forth.
tadaA celebratory scale and wobble animation.
wobbleWobbles the element with a drunk-like motion.
jelloA gelatinous, wobbly effect.
heart-beatA throbbing heart beat effect.
Entrances
fade-inFades the element in.
fade-in-downFades and slides in from above.
fade-in-upFades and slides in from below.
fade-in-leftFades and slides in from the left.
fade-in-rightFades and slides in from the right.
slide-in-downSlides in from above.
slide-in-upSlides in from below.
slide-in-leftSlides in from the left.
slide-in-rightSlides in from the right.
zoom-inZooms in from the center.
zoom-in-downZooms and slides in from above.
zoom-in-upZooms and slides in from below.
zoom-in-leftZooms and slides in from the left.
zoom-in-rightZooms and slides in from the right.
bounce-inBounces in with a scaling effect.
bounce-in-downBounces in from above.
bounce-in-upBounces in from below.
bounce-in-leftBounces in from the left.
bounce-in-rightBounces in from the right.
flip-in-xFlips in around the horizontal axis.
flip-in-yFlips in around the vertical axis.
rotate-inRotates into view.
jack-in-the-boxA surprising, popping entrance effect.
Exits
fade-outFades the element out.
fade-out-downFades and slides out to the bottom.
fade-out-upFades and slides out to the top.
fade-out-leftFades and slides out to the left.
fade-out-rightFades and slides out to the right.
slide-out-downSlides out to the bottom.
slide-out-upSlides out to the top.
slide-out-leftSlides out to the left.
slide-out-rightSlides out to the right.
zoom-outZooms out to the center.
zoom-out-downZooms and slides out to the bottom.
zoom-out-upZooms and slides out to the top.
zoom-out-leftZooms and slides out to the left.
zoom-out-rightZooms and slides out to the right.
bounce-outBounces out with a scaling effect.
bounce-out-downBounces out to the bottom.
bounce-out-upBounces out to the top.
bounce-out-leftBounces out to the left.
bounce-out-rightBounces out to the right.
flip-out-xFlips out around the horizontal axis.
flip-out-yFlips out around the vertical axis.
rotate-outRotates out of view.
hingeA dramatic exit where the element drops like a hinge.

Custom Animations

Define your own animations using CSS properties with the syntax `property(value)`.

<!-- Animate multiple CSS properties at once -->
<div data-animasis="hover:transform(scale(1.1) rotate(5deg)) opacity(0.8) | 300ms">
  Custom Animation
</div>

Advanced JavaScript API

For complete control over complex, sequential, or dynamic animations, use the `window.Animasis.timeline()` method. This method is a wrapper around the Web Animations API.

document.getElementById('run-advanced-animation')
  .addEventListener('click', () => {
    Animasis.timeline('#advanced-box', 
      [
        { transform: 'translateY(50px) scale(0.8)', opacity: 0 },
        { transform: 'translateY(-10px) scale(0.8)', offset: 0.7 },
        { transform: 'translateY(0) scale(1)', opacity: 1 }
      ], 
      {
        duration: 1200,
        easing: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)'
      }
    );
});

Get Started with Animasis.js

Just add the script tag to your HTML file before the closing `</body>` tag.

<script src="https://api.chiragganguli.com/library/js/animasis/main.js"></script>

License

Creative Commons License

Animasis.js is licensed under the Creative Commons Attribution 4.0 International License.

This license allows you to:

Share
— copy and redistribute the material in any medium or format for any purpose, even commercially.
Adapt
— remix, transform, and build upon the material for any purpose, even commercially.

Under the following terms:

Attribution
— You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.