PagerDefaults
-
Cmn
object PagerDefaults
Contains the default values used by Pager.
Summary
Constants |
||
|---|---|---|
const Int |
The default value of beyondViewportPageCount used to specify the number of pages to compose and layout before and after the visible pages. |
Cmn
|
Public functions |
||
|---|---|---|
TargetedFlingBehavior |
@ComposableA |
Cmn
|
NestedScrollConnection |
@ComposableThe default implementation of Pager's pageNestedScrollConnection. |
Cmn
|
Constants
BeyondViewportPageCount
const val BeyondViewportPageCount = 0: Int
The default value of beyondViewportPageCount used to specify the number of pages to compose and layout before and after the visible pages. It does not include the pages automatically composed and laid out by the pre-fetcher in the direction of the scroll during scroll events.
Public functions
flingBehavior
@Composable
fun flingBehavior(
state: PagerState,
pagerSnapDistance: PagerSnapDistance = PagerSnapDistance.atMost(1),
decayAnimationSpec: DecayAnimationSpec<Float> = rememberSplineBasedDecay(),
snapAnimationSpec: AnimationSpec<Float> = spring( stiffness = Spring.StiffnessMediumLow, visibilityThreshold = Int.VisibilityThreshold.toFloat(), ),
snapPositionalThreshold: @FloatRange(from = 0.0, to = 1.0) Float = 0.5f
): TargetedFlingBehavior
A snapFlingBehavior that will snap pages to the start of the layout. One can use the given parameters to control how the snapping animation will happen.
| Parameters | |
|---|---|
state: PagerState |
The |
pagerSnapDistance: PagerSnapDistance = PagerSnapDistance.atMost(1) |
A way to control the snapping destination for this |
decayAnimationSpec: DecayAnimationSpec<Float> = rememberSplineBasedDecay() |
The animation spec used to approach the target offset. When the fling velocity is large enough. Large enough means large enough to naturally decay. For single page snapping this usually never happens since there won't be enough space to run a decay animation. |
snapAnimationSpec: AnimationSpec<Float> = spring(
stiffness = Spring.StiffnessMediumLow,
visibilityThreshold = Int.VisibilityThreshold.toFloat(),
) |
The animation spec used to finally snap to the position. This animation will be often used in 2 cases: 1) There was enough space to an approach animation, the Pager will use |
snapPositionalThreshold: @FloatRange(from = 0.0, to = 1.0) Float = 0.5f |
If the fling has a low velocity (e.g. slow scroll), this fling behavior will use this snap threshold in order to determine if the pager should snap back or move forward. Use a number between 0 and 1 as a fraction of the page size that needs to be scrolled before the Pager considers it should move to the next page. For instance, if snapPositionalThreshold = 0.35, it means if this pager is scrolled with a slow velocity and the Pager scrolls more than 35% of the page size, then will jump to the next page, if not it scrolls back. Note that any fling that has high enough velocity will always move to the next page in the direction of the fling. |
| Returns | |
|---|---|
TargetedFlingBehavior |
An instance of |
| See also | |
|---|---|
snapFlingBehavior |
for more information on what which parameter controls in the overall snapping animation. The animation specs used by the fling behavior will depend on 2 factors:
If you're using single page snapping (the most common use case for |
pageNestedScrollConnection
@Composable
fun pageNestedScrollConnection(state: PagerState, orientation: Orientation): NestedScrollConnection
The default implementation of Pager's pageNestedScrollConnection.
| Parameters | |
|---|---|
state: PagerState |
state of the pager |
orientation: Orientation |
The orientation of the pager. This will be used to determine which direction the nested scroll connection will operate and react on. |