michalsnik / aos
Animate on scroll library
description README.md
:exclamation::exclamation::exclamation: This is README for aos@next :exclamation::exclamation::exclamation:
For last stable release (v2) go here
🚀 Demo
🌟 Codepen Examples
- Different built-in animations
- With anchor setting in use
- With anchor-placement and different easings
- With simple custom animations
👉 To get a better understanding how this actually works, I encourage you to check my post on CSS-tricks.
⚙ Installation
Basic
Add styles in <head>:
<link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />
Add script right before closing </body> tag, and initialize AOS:
<script src="https://unpkg.com/aos@next/dist/aos.js"></script>
<script>
AOS.init();
</script>
Using package managers
Install aos package:
yarn add aos@next- or
npm install --save aos@next
Import script, styles and initialize AOS:
import AOS from 'aos';
import 'aos/dist/aos.css'; // You can also use <link> for styles
// ..
AOS.init();
In order to make it work you'll have to make sure your build process has configured styles loader, and bundles it all correctly. If you're using Parcel however, it will work out of the box as provided.
🤔 How to use it?
1. Initialize AOS:
AOS.init();
// You can also pass an optional settings object
// below listed default settings
AOS.init({
// Global settings:
disable: false, // accepts following values: 'phone', 'tablet', 'mobile', boolean, expression or function
startEvent: 'DOMContentLoaded', // name of the event dispatched on the document, that AOS should initialize on
initClassName: 'aos-init', // class applied after initialization
animatedClassName: 'aos-animate', // class applied on animation
useClassNames: false, // if true, will add content of `data-aos` as classes on scroll
disableMutationObserver: false, // disables automatic mutations' detections (advanced)
debounceDelay: 50, // the delay on debounce used while resizing window (advanced)
throttleDelay: 99, // the delay on throttle used while scrolling the page (advanced)
// Settings that can be overridden on per-element basis, by `data-aos-*` attributes:
offset: 120, // offset (in px) from the original trigger point
delay: 0, // values from 0 to 3000, with step 50ms
duration: 400, // values from 0 to 3000, with step 50ms
easing: 'ease', // default easing for AOS animations
once: false, // whether animation should happen only once - while scrolling down
mirror: false, // whether elements should animate out while scrolling past them
anchorPlacement: 'top-bottom', // defines which position of the element regarding to window should trigger the animation
});
2. Set animation using data-aos attribute:
<div data-aos="fade-in"></div>
And adjust behaviour by using data-aos-* attributes:
<div
data-aos="fade-up"
data-aos-offset="200"
data-aos-delay="50"
data-aos-duration="1000"
data-aos-easing="ease-in-out"
data-aos-mirror="true"
data-aos-once="false"
data-aos-anchor-placement="top-center"
>
</div>
See full list of all animations, easings and anchor placements
Anchor
There is also a setting that can be used only on per-element basis:
data-aos-anchor- element whose offset will be used to trigger animation instead of an actual one.
Examples:
<div data-aos="fade-up" data-aos-anchor=".other-element"></div>
This way you can trigger animation on one element, while you scroll to another - useful in animating fixed elements.
API
AOS object is exposed as a global variable, for now there are three methods available:
init- initialize AOSrefresh- recalculate all offsets and positions of elements (called on window resize)refreshHard- reinit array with AOS elements and triggerrefresh(called on DOM changes that are related toaoselements)
Example execution:
AOS.refresh();
By default AOS is watching for DOM changes and if there are any new elements loaded asynchronously or when something is removed from DOM it calls refreshHard automatically. In browsers that don't support MutationObserver like IE you might need to call AOS.refreshHard() by yourself.
refresh method is called on window resize and so on, as it doesn't require to build new store with AOS elements and should be as light as possible.
JS Events
AOS dispatches two events on document: aos:in and aos:out whenever any element animates in or out, so that you can do extra stuff in JS:
document.addEventListener('aos:in', ({ detail }) => {
console.log('animated in', detail);
});
document.addEventListener('aos:out', ({ detail }) => {
console.log('animated out', detail);
});
You can also tell AOS to trigger custom event on specific element, by setting data-aos-id attribute:
<div data-aos="fade-in" data-aos-id="super-duper"></div>
Then you'll be able to listen for two custom events then:
aos:in:super-duperaos:out:super-duper
Recipes:
Adding custom animations:
Sometimes built-in animations are just not enough. Let's say you need one box to have different animation depending on resolution. Here's how you could do it:
[data-aos="new-animation"] {
opacity: 0;
transition-property: transform, opacity;
&.aos-animate {
opacity: 1;
}
@media screen and (min-width: 768px) {
transform: translateX(100px);
&.aos-animate {
transform: translateX(0);
}
}
}
Then use it in HTML:
<div data-aos="new-animation"></div>
The element will only animate opacity on mobile devices, but from 768px width it'll also slide from right to left.
Adding custom easing:
Similar to animations you can add custom easings:
[data-aos] {
body[data-aos-easing="new-easing"] &,
&[data-aos][data-aos-easing="new-easing"] {
transition-timing-function: cubic-bezier(.250, .250, .750, .750);
}
}
Customizing default animations distance
Default distance for built-in animations is 100px. As long as you're using SCSS though, you can override it:
$aos-distance: 200px; // It has to be above import
@import 'node_modules/aos/src/sass/aos.scss';
You have to however configure your build process to allow it to import styles from node_modules beforehand.
Integrating external CSS animation library (e.g. Animate.css):
Use animatedClassName to change default behaviour of AOS, to apply class names placed inside data-aos on scroll.
<div data-aos="fadeInUp"></div>
AOS.init({
useClassNames: true,
initClas
More in Uncategorized

openclaw / openclaw
OpenClaw is an open-source personal AI assistant that runs on your own devices and connects to the communication platforms you already use. It provides a fast, always-available assistant that can respond, listen, speak, and perform tasks across desktop and mobile devices.

obra / superpowers
An agentic skills framework & software development methodology that works.

affaan-m / everything-claude-code
The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

NousResearch / hermes-agent
The self-improving AI agent built by Nous Research. It's the only agent with a built-in learning loop — it creates skills from experience, improves them during use, nudges itself to persist knowledge, searches its own past conversations, and builds a deepening model of who you are across sessions.
