Skip to main content

PagerState

Struct PagerState 

Source
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

Source

pub fn new(page_count: usize) -> Self

Source

pub fn position(&self) -> f32

The continuous position in pages.

Source

pub fn current_page(&self) -> usize

The page closest to the current position.

Source

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.

Source

pub fn page_count(&self) -> usize

Source

pub fn set_page(&self, page: usize)

Animate to page, clamped to the page range.

Source

pub fn animate_scroll_to_page(&self, page: usize, spec: AnimationSpec)

Animate to page with an explicit spec.

Source

pub fn scroll_to_page(&self, page: usize)

Jump to page without animating.

Source

pub fn set_page_count(&self, count: usize)

Update the page count, clamping the position into range.

Source

pub fn is_animating(&self) -> bool

Whether a snap animation is currently running.

Source

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 PagerState
where *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
where Rc<RefCell<PagerInner>>: Unpin, Rc<RefCell<DragState>>: Unpin, Rc<Cell<f32>>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for PagerState
where *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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.