# chrisbanes/snapper architecture

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

- Interactive diagram: https://gitdiagram.com/chrisbanes/snapper
- Repository: https://github.com/chrisbanes/snapper

## Overview

Snapper is a deprecated Jetpack Compose library that adds snapping fling behavior to LazyColumn and LazyRow. A developer creates a remembered behavior for a LazyListState, then supplies it to a scrolling layout. When a fling occurs, Compose dispatches to Snapper, which consults its lazy-list adapter for item and viewport information, chooses a target (with a customizable snap index), and runs decay and spring animations to settle the list. The source excerpts show these core responsibilities; wiring beyond the documented API and sampled code is omitted.

Main entry points: [`lib/src/main/kotlin/dev/chrisbanes/snapper/SnapperFlingBehavior.kt`](https://github.com/chrisbanes/snapper/blob/main/lib/src/main/kotlin/dev/chrisbanes/snapper/SnapperFlingBehavior.kt) (Fling behavior), [`lib/src/main/kotlin/dev/chrisbanes/snapper/LazyList.kt`](https://github.com/chrisbanes/snapper/blob/main/lib/src/main/kotlin/dev/chrisbanes/snapper/LazyList.kt) (Remember behavior)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Snapper API"]
  node_api_entry["Remember behavior<br/>[LazyList.kt]"]
end

subgraph group_layout["List Adaptation"]
  node_adapter["Lazy-list adapter<br/>[LazyList.kt]"]
end

subgraph group_fling["Fling Execution"]
  node_behavior["Fling behavior"]
end

node_developer(("Compose developer"))
node_lazylist["LazyColumn / LazyRow"]
node_layout_state["LazyListState"]
node_compose_animation["Compose animation"]

node_developer -->|"creates behavior"| node_api_entry
node_api_entry -->|"builds adapter"| node_adapter
node_api_entry -->|"remembers behavior"| node_behavior
node_developer -->|"supplies behavior"| node_lazylist
node_lazylist -->|"dispatches fling"| node_behavior
node_adapter -->|"reads layout"| node_layout_state
node_behavior -->|"queries layout"| node_adapter
node_behavior -->|"runs animations"| node_compose_animation
node_behavior -->|"scrolls list"| node_lazylist

click node_api_entry "https://github.com/chrisbanes/snapper/blob/main/lib/src/main/kotlin/dev/chrisbanes/snapper/LazyList.kt"
click node_adapter "https://github.com/chrisbanes/snapper/blob/main/lib/src/main/kotlin/dev/chrisbanes/snapper/LazyList.kt"
click node_behavior "https://github.com/chrisbanes/snapper/blob/main/lib/src/main/kotlin/dev/chrisbanes/snapper/SnapperFlingBehavior.kt"

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_api_entry toneBlue
class node_adapter toneAmber
class node_behavior toneMint
class node_developer,node_lazylist,node_layout_state,node_compose_animation toneIndigo
```

## Components

### Snapper API

- [Remember behavior](https://github.com/chrisbanes/snapper/blob/main/lib/src/main/kotlin/dev/chrisbanes/snapper/LazyList.kt): `lib/src/main/kotlin/dev/chrisbanes/snapper/LazyList.kt`

### List Adaptation

- [Lazy-list adapter](https://github.com/chrisbanes/snapper/blob/main/lib/src/main/kotlin/dev/chrisbanes/snapper/LazyList.kt): `lib/src/main/kotlin/dev/chrisbanes/snapper/LazyList.kt`

### Fling Execution

- [Fling behavior](https://github.com/chrisbanes/snapper/blob/main/lib/src/main/kotlin/dev/chrisbanes/snapper/SnapperFlingBehavior.kt): `lib/src/main/kotlin/dev/chrisbanes/snapper/SnapperFlingBehavior.kt`

### Other components

- **Compose developer**
- **LazyColumn / LazyRow**
- **LazyListState**
- **Compose animation**

## Connections

- Compose developer → Remember behavior: creates behavior
- Remember behavior → Lazy-list adapter: builds adapter
- Remember behavior → Fling behavior: remembers behavior
- Compose developer → LazyColumn / LazyRow: supplies behavior
- LazyColumn / LazyRow → Fling behavior: dispatches fling
- Lazy-list adapter → LazyListState: reads layout
- Fling behavior → Lazy-list adapter: queries layout
- Fling behavior → Compose animation: runs animations
- Fling behavior → LazyColumn / LazyRow: scrolls list
