pub struct PagerState { /* private fields */ }Expand description
Continuous position and snap animation of a pager.
position is measured in pages: 2.0 means page index 2 is settled at the
viewport origin, 2.5 means the pager has been dragged half a page
backwards. current_page is the nearest page.
Implementations§
Source§impl PagerState
impl PagerState
pub fn new(page_count: usize) -> Self
Sourcepub fn current_page(&self) -> usize
pub fn current_page(&self) -> usize
The page closest to the current position.
Sourcepub fn current_page_offset_fraction(&self) -> f32
pub fn current_page_offset_fraction(&self) -> f32
How far the pager sits from current_page, in
-0.5..=0.5 pages. Negative means the next page is being revealed.
pub fn page_count(&self) -> usize
Sourcepub fn animate_scroll_to_page(&self, page: usize, spec: AnimationSpec)
pub fn animate_scroll_to_page(&self, page: usize, spec: AnimationSpec)
Animate to page with an explicit spec.
Sourcepub fn scroll_to_page(&self, page: usize)
pub fn scroll_to_page(&self, page: usize)
Jump to page without animating.
Sourcepub fn set_page_count(&self, count: usize)
pub fn set_page_count(&self, count: usize)
Update the page count, clamping the position into range.
Sourcepub fn is_animating(&self) -> bool
pub fn is_animating(&self) -> bool
Whether a snap animation is currently running.
Sourcepub fn scroll_by_pages(&self, delta_pages: f32)
pub fn scroll_by_pages(&self, delta_pages: f32)
Move the pager by delta_pages pages without animating. Positive
values reveal later pages, negative earlier ones.
Auto Trait Implementations§
impl !RefUnwindSafe for PagerState
impl !Send for PagerState
impl !Sync for PagerState
impl !UnwindSafe for PagerState
impl Forget for PagerState
impl Freeze for PagerStatewhere
*const RcInner<RefCell<PagerInner>> is !null: Freeze,
PhantomData<RcInner<RefCell<PagerInner>>>: Freeze,
*const RcInner<RefCell<DragState>> is !null: Freeze,
PhantomData<RcInner<RefCell<DragState>>>: Freeze,
*const RcInner<Cell<f32>> is !null: Freeze,
PhantomData<RcInner<Cell<f32>>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
impl Move for PagerState
impl Unpin for PagerState
impl UnsafeUnpin for PagerStatewhere
*const RcInner<RefCell<PagerInner>> is !null: UnsafeUnpin,
PhantomData<RcInner<RefCell<PagerInner>>>: UnsafeUnpin,
*const RcInner<RefCell<DragState>> is !null: UnsafeUnpin,
PhantomData<RcInner<RefCell<DragState>>>: UnsafeUnpin,
*const RcInner<Cell<f32>> is !null: UnsafeUnpin,
PhantomData<RcInner<Cell<f32>>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more