AOS.js

Documentation

Discover how to use AOS.js to create scroll-based animations. Everything you need to implement, customize, and extend animation capabilities.

Getting Started

Installation

1 NPM

npm install aos@latest

Include in your JavaScript project via NPM with tree-shaking support.

2 CDN

<script src="https://cdn.jsdelivr.net/npm/aos@latest/dist/aos.js"></script>

Use the official CDN for quick integration without build tools.

Initialization

<div data-aos="fade-up">
  Your animated content
</div>
AOS.init({
  duration: 1000,
  once: true
});

Configuration

Options

  • duration - Animation duration in milliseconds
  • offset - Distance from viewport before animation triggers
  • easing - Animation easing method

Methods

  • destroy() - Removes AOS animations from all elements
  • refresh() - Recalculates positions (use after DOM changes)

Supported Animations

70+ built-in animations using Animate.css framework. Combine multiple animations with ease.

fade-up
fade-down
fade-left
fade-right
flip-up
zoom-in
zoom-out
slide-up
slide-down
rotate

View full list in Animations Reference

Configuration Options

duration

Default: 800ms – Controls animation duration. Can be set per element.

AOS.init({ duration: 1200 });

offset

Default: 120px – How many pixels from the viewport to trigger animation.

AOS.init({ offset: 100 });

once

Default: false – Run the animation only once when element is visible.

AOS.init({ once: true });

easing

Default: 'ease-out-back' – Animation easing function.

AOS.init({ easing: 'ease-in-out-cubic' });

Advanced Usage

Custom Animations

How to create custom animation sequences:

Combine multiple AOS animations with timing delays for complex entry sequences.

<div class="aos-sequence">
  <div data-aos="fade-up" data-aos-delay="100">First</div>
  <div data-aos="zoom-in" data-aos-delay="300">Second</div>
  <div data-aos="slide-right" data-aos-delay="500">Third</div>
</div>
document.querySelectorAll('.aos-sequence').forEach(container => {
  AOS.init({
    parent: container,
    delay: 100,
    duration: 1000
  });
});

Responsive Animations

Adaptive animations based on screen size:

Use device specific animations by setting different options for various breakpoints.

AOS.init({
  duration: function () {
    return window.innerWidth < 768 ? 500 : 1000;
  }()
});

Changelog

v5.0.0

Released 2025-03-15

  • New: Added 20+ modern animations (flipInX, pulse, rubberBand)
  • Improvement: Smooth edge animations with GPU acceleration
  • Enhancement: Improved mobile performance with 60fps smoothness
v4.1.2

Released 2025-01-15

  • Fix: Correct handling of vertical scrolling in nested containers
  • Fix: Smooth scroll restoration between page visits