How chrisbanes/snapper works
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: SnapperFlingBehavior.kt Fling behavior · LazyList.kt Remember behavior
Components 7
Snapper API
- Remember behavior
lib/src/main/kotlin/dev/chrisbanes/snapper/LazyList.kt
List Adaptation
- Lazy-list adapter
lib/src/main/kotlin/dev/chrisbanes/snapper/LazyList.kt
Fling Execution
- Fling behavior
lib/src/main/kotlin/dev/chrisbanes/snapper/SnapperFlingBehavior.kt
Other components
- Compose developer
- LazyColumn / LazyRow
- LazyListState
- Compose animation
Connections 9
- 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