androidx.compose.foundation
OverscrollEffect
Interface · from org.jetbrains.compose.foundation:foundation:1.12.2
No hand-written docs yet.
An OverscrollEffect represents a visual effect that displays when the edges of a scrolling container have been reached with a scroll or fling. To create an instance of the default / currently provided OverscrollFactory, use rememberOverscrollEffect.
interface OverscrollEffect
Used by
Parameters that take a OverscrollEffect.
anchoredDraggable(overscrollEffect)HorizontalPager(overscrollEffect)horizontalScroll(overscrollEffect)LazyColumn(overscrollEffect)LazyHorizontalGrid(overscrollEffect)LazyHorizontalStaggeredGrid(overscrollEffect)LazyRow(overscrollEffect)LazyVerticalGrid(overscrollEffect)LazyVerticalStaggeredGrid(overscrollEffect)overscroll(overscrollEffect)scrollable(overscrollEffect)scrollable2D(overscrollEffect)scrollableArea(overscrollEffect)VerticalPager(overscrollEffect)verticalScroll(overscrollEffect)
Properties
isInProgress
val isInProgress: Boolean
Whether this OverscrollEffect is currently displaying overscroll.
nodeSince 1.8
val node: DelegatableNode
The DelegatableNode that will render this OverscrollEffect and provide any required size or other information to this effect.
Functions
applyToScroll
fun applyToScroll(
delta: Offset,
source: NestedScrollSource,
performScroll: (Offset) -> Offset,
): Offset
Applies overscroll to performScroll. performScroll should represent a drag / scroll, and returns the amount of delta consumed, so in simple cases the amount of overscroll to show should be equal to delta - performScroll(delta). The OverscrollEffect can optionally consume some delta before calling performScroll, such as to release any existing tension. The implementation must call performScroll exactly once. This function should return the sum of all the delta that was consumed during this operation - both by the overscroll and performScroll.
applyToFling
fun applyToFling(
velocity: Velocity,
performFling: suspend (Velocity) -> Velocity,
)
Applies overscroll to performFling. performFling should represent a fling (the release of a drag or scroll), and returns the amount of Velocity consumed, so in simple cases the amount of overscroll to show should be equal to velocity - performFling(velocity). The OverscrollEffect can optionally consume some Velocity before calling performFling, such as to release any existing tension. The implementation must call performFling exactly once.
Library docs
An OverscrollEffect represents a visual effect that displays when the edges of a scrolling
container have been reached with a scroll or fling. To create an instance of the default /
currently provided OverscrollFactory, use rememberOverscrollEffect.
To implement, make sure to override node - this has a default implementation for compatibility
reasons, but is required for an OverscrollEffect to render.
OverscrollEffect conceptually 'decorates' scroll / fling events: consuming some of the delta or
velocity before and/or after the event is consumed by the scrolling container. applyToScroll
applies overscroll to a scroll event, and applyToFling applies overscroll to a fling.
Higher level components such as androidx.compose.foundation.lazy.LazyColumn will automatically
configure an OverscrollEffect for you. To use a custom OverscrollEffect you first need to provide
it with scroll and/or fling events - usually by providing it to a
androidx.compose.foundation.gestures.scrollable. Then you can draw the effect on top of the
scrolling content using Modifier.overscroll.