pub struct ScrollPosition {
pub offset: (f32, f32),
pub max: (f32, f32),
pub viewport: Size,
}Expand description
Where a scroll region is, and how much room it has, at the moment it is reported.
Handed to Widget::on_scroll. Everything an application
could want to know about a position is derivable from these three, and they are the
three the layout already knows — no measurement is done to produce one.
Fields§
§offset: (f32, f32)The offsets (x, y) the region is resting or moving at. Measured from the end
its axis starts at, so a reversed list at 0 is at its newest end.
max: (f32, f32)The largest offsets the content may rest at, per axis. 0 = that axis has
nothing to scroll.
viewport: SizeThe window the content is seen through.
Implementations§
Source§impl ScrollPosition
impl ScrollPosition
Sourcepub fn of(area: &Scrollable, offset: (f32, f32)) -> Self
pub fn of(area: &Scrollable, offset: (f32, f32)) -> Self
The position of area, resting at offset.
Sourcepub fn x(&self) -> ScrollMetrics
pub fn x(&self) -> ScrollMetrics
The horizontal axis, as the physics states it.
Sourcepub fn y(&self) -> ScrollMetrics
pub fn y(&self) -> ScrollMetrics
The vertical axis, as the physics states it.
Sourcepub fn fraction_y(&self) -> f32
pub fn fraction_y(&self) -> f32
How far down the content is, 0.0..=1.0.
Zero when there is nothing to scroll, which is the only answer that is not a lie: a list shorter than its window is neither at its beginning nor at its end, and a progress rule over it should read empty rather than full.
Sourcepub fn fraction_x(&self) -> f32
pub fn fraction_x(&self) -> f32
How far across the content is, 0.0..=1.0. See ScrollPosition::fraction_y.
Sourcepub fn remaining_y(&self) -> f32
pub fn remaining_y(&self) -> f32
Pixels of content left below the window; 0 at the end, and 0 when there is
nothing to scroll.
This is what a load-more asks: remaining_y() < 400.0 is “the end is
coming”, said in the unit the reader is moving in rather than as a percentage,
which means something quite different in a list of ten and a list of ten
thousand.
Sourcepub fn remaining_x(&self) -> f32
pub fn remaining_x(&self) -> f32
Pixels of content left past the trailing edge. See ScrollPosition::remaining_y.