# michalsnik/aos architecture

> Architecture diagram of the GitHub repository michalsnik/aos, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/michalsnik/aos
- Repository: https://github.com/michalsnik/aos

## Overview

AOS is a browser-side, CSS-driven scroll-animation library. A page initializes it with options and `data-aos` elements; AOS discovers those elements, prepares per-element trigger positions, and responds to scrolling by applying animation classes and dispatching events. Resize and orientation changes recalculate positions, while DOM mutations can trigger a hard refresh. The README also documents per-element configuration, custom animations/easings, and integration with external CSS animation libraries. Relationships reflect the sampled source and README; Sass internals are represented by the documented styling entry point rather than inferred imports.

Main entry points: [`src/js/aos.js`](https://github.com/michalsnik/aos/blob/next/src/js/aos.js) (AOS API), [`src/js/helpers/prepare.js`](https://github.com/michalsnik/aos/blob/next/src/js/helpers/prepare.js) (Element preparation), [`src/js/helpers/offsetCalculator.js`](https://github.com/michalsnik/aos/blob/next/src/js/helpers/offsetCalculator.js) (Trigger positions), [`src/js/helpers/handleScroll.js`](https://github.com/michalsnik/aos/blob/next/src/js/helpers/handleScroll.js) (Scroll handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime orchestration"]
  node_aos["AOS API<br/>[aos.js]"]
  node_scroll["Scroll handling<br/>[handleScroll.js]"]
  node_device["Device detection<br/>[detector.js]"]
  node_mutations["Mutation observer<br/>[observer.js]"]
end

subgraph group_element["Element preparation"]
  node_discovery["Element discovery<br/>[elements.js]"]
  node_preparation["Element preparation<br/>[prepare.js]"]
  node_inline["Inline options<br/>[getInlineOption.js]"]
  node_positions["Trigger positions"]
  node_offset["DOM offset<br/>[offset.js]"]
end

subgraph group_style["Animation styling"]
  node_styles["Animation styles<br/>[aos.scss]"]
end

node_page(("Page integrator"))

node_page -->|"initializes"| node_aos
node_page -->|"scrolls page"| node_aos
node_aos -->|"discovers elements"| node_discovery
node_aos -->|"prepares elements"| node_preparation
node_aos -->|"handles scroll"| node_scroll
node_aos -->|"checks support"| node_device
node_aos -->|"registers watcher"| node_mutations
node_aos -->|"imports styles"| node_styles
node_preparation -->|"reads options"| node_inline
node_preparation -->|"calculates triggers"| node_positions
node_positions -->|"reads overrides"| node_inline
node_positions -->|"measures elements"| node_offset
node_scroll -->|"checks compatibility"| node_device
node_mutations -->|"requests hard refresh"| node_aos

click node_aos "https://github.com/michalsnik/aos/blob/next/src/js/aos.js"
click node_discovery "https://github.com/michalsnik/aos/blob/next/src/js/helpers/elements.js"
click node_preparation "https://github.com/michalsnik/aos/blob/next/src/js/helpers/prepare.js"
click node_inline "https://github.com/michalsnik/aos/blob/next/src/js/helpers/getInlineOption.js"
click node_positions "https://github.com/michalsnik/aos/blob/next/src/js/helpers/offsetCalculator.js"
click node_offset "https://github.com/michalsnik/aos/blob/next/src/js/libs/offset.js"
click node_scroll "https://github.com/michalsnik/aos/blob/next/src/js/helpers/handleScroll.js"
click node_device "https://github.com/michalsnik/aos/blob/next/src/js/helpers/detector.js"
click node_mutations "https://github.com/michalsnik/aos/blob/next/src/js/libs/observer.js"
click node_styles "https://github.com/michalsnik/aos/blob/next/src/sass/aos.scss"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_aos,node_scroll,node_device,node_mutations toneBlue
class node_discovery,node_preparation,node_inline,node_positions,node_offset toneAmber
class node_styles toneMint
class node_page toneIndigo
```

## Components

### Runtime orchestration

- [AOS API](https://github.com/michalsnik/aos/blob/next/src/js/aos.js): `src/js/aos.js`
- [Scroll handling](https://github.com/michalsnik/aos/blob/next/src/js/helpers/handleScroll.js): `src/js/helpers/handleScroll.js`
- [Device detection](https://github.com/michalsnik/aos/blob/next/src/js/helpers/detector.js): `src/js/helpers/detector.js`
- [Mutation observer](https://github.com/michalsnik/aos/blob/next/src/js/libs/observer.js): `src/js/libs/observer.js`

### Element preparation

- [Element discovery](https://github.com/michalsnik/aos/blob/next/src/js/helpers/elements.js): `src/js/helpers/elements.js`
- [Element preparation](https://github.com/michalsnik/aos/blob/next/src/js/helpers/prepare.js): `src/js/helpers/prepare.js`
- [Inline options](https://github.com/michalsnik/aos/blob/next/src/js/helpers/getInlineOption.js): `src/js/helpers/getInlineOption.js`
- [Trigger positions](https://github.com/michalsnik/aos/blob/next/src/js/helpers/offsetCalculator.js): `src/js/helpers/offsetCalculator.js`
- [DOM offset](https://github.com/michalsnik/aos/blob/next/src/js/libs/offset.js): `src/js/libs/offset.js`

### Animation styling

- [Animation styles](https://github.com/michalsnik/aos/blob/next/src/sass/aos.scss): `src/sass/aos.scss`

### Other components

- **Page integrator**

## Connections

- Page integrator → AOS API: initializes (evidence: `README.md`)
- Page integrator → AOS API: scrolls page (evidence: `src/js/aos.js`)
- AOS API → Element discovery: discovers elements (evidence: `src/js/aos.js`)
- AOS API → Element preparation: prepares elements (evidence: `src/js/aos.js`)
- AOS API → Scroll handling: handles scroll (evidence: `src/js/aos.js`)
- AOS API → Device detection: checks support (evidence: `src/js/aos.js`)
- AOS API → Mutation observer: registers watcher (evidence: `src/js/aos.js`)
- AOS API → Animation styles: imports styles (evidence: `src/js/aos.js`)
- Element preparation → Inline options: reads options (evidence: `src/js/helpers/prepare.js`)
- Element preparation → Trigger positions: calculates triggers (evidence: `src/js/helpers/prepare.js`)
- Trigger positions → Inline options: reads overrides (evidence: `src/js/helpers/offsetCalculator.js`)
- Trigger positions → DOM offset: measures elements (evidence: `src/js/helpers/offsetCalculator.js`)
- Scroll handling → Device detection: checks compatibility (evidence: `src/js/helpers/handleScroll.js`)
- Mutation observer → AOS API: requests hard refresh (evidence: `src/js/aos.js`)
