-
- All Implemented Interfaces:
-
androidx.compose.foundation.gestures.ScrollableState
@Deprecated(message = accompanist/pager is deprecated. The androidx.compose equivalent of Insets is Pager. For more migration information, please visit https://google.github.io/accompanist/pager/#migration , replaceWith = @ReplaceWith(imports = {androidx.compose.foundation.pager.PagerState}, expression = PagerState(currentPage = currentPage)))@Stable() public final class PagerState implements ScrollableState
A state object that can be hoisted to control and observe scrolling for HorizontalPager.
In most cases, this will be created via rememberPagerState.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classPagerState.Companion
-
Field Summary
Fields Modifier and Type Field Description private final InteractionSourceinteractionSourceprivate final IntegerpageCountprivate IntegercurrentPageprivate final FloatcurrentPageOffsetprivate final IntegertargetPageprivate final BooleanisScrollInProgressprivate final BooleancanScrollBackwardprivate final BooleancanScrollForwardprivate final BooleanlastScrolledBackwardprivate final BooleanlastScrolledForward
-
Constructor Summary
Constructors Constructor Description PagerState(Integer currentPage)
-
Method Summary
Modifier and Type Method Description final InteractionSourcegetInteractionSource()final IntegergetPageCount()The number of pages to display. final IntegergetCurrentPage()final UnitsetCurrentPage(Integer currentPage)final FloatgetCurrentPageOffset()The current offset from the start of currentPage, as a ratio of the page width. final IntegergetTargetPage()BooleangetIsScrollInProgress()BooleangetCanScrollBackward()BooleangetCanScrollForward()BooleangetLastScrolledBackward()BooleangetLastScrolledForward()final UnitanimateScrollToPage(@IntRange(from = 0.toLong()) Integer page, @FloatRange(from = 0.0.toDouble(), to = 1.0.toDouble()) Float pageOffset, AnimationSpec<Float> animationSpec, Float initialVelocity, Boolean skipPages)final UnitanimateScrollToPage(@IntRange(from = 0.toLong()) Integer page, @FloatRange(from = -1.0.toDouble(), to = 1.0.toDouble()) Float pageOffset)Animate (smooth scroll) to the given page to the middle of the viewport. final UnitscrollToPage(@IntRange(from = 0.toLong()) Integer page, @FloatRange(from = -1.0.toDouble(), to = 1.0.toDouble()) Float pageOffset)Instantly brings the item at page to the middle of the viewport. Unitscroll(MutatePriority scrollPriority, SuspendFunction1<ScrollScope, Unit> block)FloatdispatchRawDelta(Float delta)StringtoString()-
-
Constructor Detail
-
PagerState
PagerState(Integer currentPage)
- Parameters:
currentPage- the initial value for PagerState.currentPage
-
-
Method Detail
-
getInteractionSource
final InteractionSource getInteractionSource()
-
getPageCount
@IntRange(from = 0.toLong()) final Integer getPageCount()
The number of pages to display.
-
getCurrentPage
@IntRange(from = 0.toLong()) final Integer getCurrentPage()
-
setCurrentPage
final Unit setCurrentPage(Integer currentPage)
-
getCurrentPageOffset
final Float getCurrentPageOffset()
The current offset from the start of currentPage, as a ratio of the page width.
To update the scroll position, use scrollToPage or animateScrollToPage.
-
getTargetPage
final Integer getTargetPage()
-
getIsScrollInProgress
Boolean getIsScrollInProgress()
-
getCanScrollBackward
Boolean getCanScrollBackward()
-
getCanScrollForward
Boolean getCanScrollForward()
-
getLastScrolledBackward
Boolean getLastScrolledBackward()
-
getLastScrolledForward
Boolean getLastScrolledForward()
-
animateScrollToPage
final Unit animateScrollToPage(@IntRange(from = 0.toLong()) Integer page, @FloatRange(from = 0.0.toDouble(), to = 1.0.toDouble()) Float pageOffset, AnimationSpec<Float> animationSpec, Float initialVelocity, Boolean skipPages)
-
animateScrollToPage
final Unit animateScrollToPage(@IntRange(from = 0.toLong()) Integer page, @FloatRange(from = -1.0.toDouble(), to = 1.0.toDouble()) Float pageOffset)
Animate (smooth scroll) to the given page to the middle of the viewport.
Cancels the currently running scroll, if any, and suspends until the cancellation is complete.
- Parameters:
page- the page to animate to.pageOffset- the percentage of the page size to offset, from the start of page.
-
scrollToPage
final Unit scrollToPage(@IntRange(from = 0.toLong()) Integer page, @FloatRange(from = -1.0.toDouble(), to = 1.0.toDouble()) Float pageOffset)
Instantly brings the item at page to the middle of the viewport.
Cancels the currently running scroll, if any, and suspends until the cancellation is complete.
- Parameters:
page- the page to snap to.pageOffset- the percentage of the page size to offset, from the start of page.
-
scroll
Unit scroll(MutatePriority scrollPriority, SuspendFunction1<ScrollScope, Unit> block)
-
dispatchRawDelta
Float dispatchRawDelta(Float delta)
-
-
-
-