Skip to content

Overview

Maven Central

Snapper is a library which brings snapping to the Compose scrolling layouts (currently LazyColumn and LazyRow):

The basic usage looks like so:

val lazyListState = rememberLazyListState()

LazyRow(
    state = lazyListState,
    flingBehavior = rememberSnapperFlingBehavior(lazyListState),
) {
    // content
}

API Summary

The API is generally split into a few things:

  • SnapperFlingBehavior, which is what apps provide to scrollable containers.
  • A number of remember functions allowing easy use of SnapperFlingBehavior from composables.
  • SnapperFlingLayoutInfo, which is an facade class allowing SnapperFlingBehavior to interact with different scrollable container state in a generic way.
  • Implementations of SnapperFlingLayoutInfo for easy integration, such as LazyListFlingLayoutInfo.

For examples, refer to the samples.

Download

Maven Central

repositories {
    mavenCentral()
}

dependencies {
    implementation "dev.chrisbanes.snapper:snapper:<version>"
}

Snapshots of the development version are available in Sonatype's snapshots repository. These are updated on every commit.

License

Copyright 2021 Chris Banes

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.