{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

ScrollExtensionsKt

public final class ScrollExtensionsKt


Summary

Public methods

static final float
animateScrollBy(
    @NonNull ScrollableState receiver,
    float value,
    @NonNull AnimationSpec<@NonNull Float> animationSpec
)

Scroll by value pixels with animation.

static final float
scrollBy(@NonNull ScrollableState receiver, float value)

Jump instantly by value pixels.

static final void
stopScroll(
    @NonNull ScrollableState receiver,
    @NonNull MutatePriority scrollPriority
)

Stop and suspend until any ongoing animation, smooth scrolling, fling, or any other scroll occurring via ScrollableState.scroll is terminated.

Public methods

animateScrollBy

public static final float animateScrollBy(
    @NonNull ScrollableState receiver,
    float value,
    @NonNull AnimationSpec<@NonNull Float> animationSpec
)

Scroll by value pixels with animation.

Cancels the currently running scroll, if any, and suspends until the cancellation is complete.

Parameters
float value

number of pixels to scroll by

@NonNull AnimationSpec<@NonNull Float> animationSpec

AnimationSpec to be used for this scrolling

Returns
float

the amount of scroll consumed

scrollBy

public static final float scrollBy(@NonNull ScrollableState receiver, float value)

Jump instantly by value pixels.

Cancels the currently running scroll, if any, and suspends until the cancellation is complete.

Parameters
float value

number of pixels to scroll by

Returns
float

the amount of scroll consumed

See also
animateScrollBy

for an animated version

stopScroll

public static final void stopScroll(
    @NonNull ScrollableState receiver,
    @NonNull MutatePriority scrollPriority
)

Stop and suspend until any ongoing animation, smooth scrolling, fling, or any other scroll occurring via ScrollableState.scroll is terminated.

Parameters
@NonNull MutatePriority scrollPriority

scrolls that run with this priority or lower will be stopped