Migrate from AOS
MOS is API-compatible with AOS where practical. In many cases you only need to swap the script and CSS imports, and rename attributes.
1. Install MOS and remove AOS
Section titled “1. Install MOS and remove AOS”npm uninstall aosnpm install motion-on-scrollpnpm remove aospnpm add motion-on-scrollyarn remove aosyarn add motion-on-scroll2. Replace the script and CSS import
Section titled “2. Replace the script and CSS import”<link rel="stylesheet" href="bower_components/aos/dist/aos.css" />
<script type="module"> import AOS from 'aos'; AOS.init({ duration: 600, once: true });</script>The bare motion-on-scroll import below must be resolved by a bundler such as Vite or Astro (or an import map). It will not work in a plain HTML page served as-is.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/motion-on-scroll@latest/dist/mos.css" />
<script type="module"> import { MOS } from 'motion-on-scroll'; MOS.init({ duration: 600, once: true });</script>If you loaded AOS with a <script> tag instead, use the standalone build, which exposes a global MOS the same way AOS exposes AOS:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/motion-on-scroll@latest/dist/mos.css" /><script src="https://cdn.jsdelivr.net/npm/motion-on-scroll@latest/dist/mos.global.js"></script><script> MOS.init({ duration: 600, once: true });</script>3. Rename data attributes
Section titled “3. Rename data attributes”| AOS | MOS | Notes |
|---|---|---|
data-aos |
data-mos |
Animation preset name |
data-aos-offset |
data-mos-offset |
Positive number in px |
data-aos-delay |
data-mos-delay |
ms |
data-aos-duration |
data-mos-duration |
ms |
data-aos-easing |
data-mos-easing |
Easing keyword or cubic-bezier() |
data-aos-anchor |
data-mos-anchor |
New trigger for animation |
data-aos-anchor-placement |
data-mos-anchor-placement |
9 keyword combos |
data-aos-once |
data-mos-once |
Boolean |
data-aos-mirror |
data-mos-mirror |
Boolean |
data-aos-id |
data-mos-id |
Used for mos:in:<id> / mos:out:<id> events |
4. Global options equivalence
Section titled “4. Global options equivalence”| AOS option | MOS option | Default |
|---|---|---|
offset |
offset |
120 |
duration |
duration |
400 |
delay |
delay |
0 |
easing |
easing |
'ease' |
once |
once |
false |
disable |
disable |
false |
mirror |
mirror |
false |
throttleDelay |
throttleDelay |
99 |
debounceDelay |
debounceDelay |
50 |
startEvent |
startEvent |
'DOMContentLoaded' |
disableMutationObserver |
disableMutationObserver |
false |
anchorPlacement |
anchorPlacement |
'top-bottom' |
initClassName |
initClassName |
'mos-init' (AOS: 'aos-init') |
animatedClassName |
animatedClassName |
'mos-animate' (AOS: 'aos-animate') |
useClassNames |
useClassNames |
false |
The aos:in / aos:out events become mos:in / mos:out.
5. Verify animation presets
Section titled “5. Verify animation presets”MOS ships all of the AOS presets. Any custom animations can be replicated by registering custom presets.
You’re done! Your site now enjoys GPU-accelerated, browser-native scroll animations—Motion uses the Web Animations API when possible, and gracefully falls back to JavaScript (requestAnimationFrame) for values WAAPI can’t handle.