pub struct ScrollState {Show 13 fields
pub offset: Point,
pub accum: (f32, f32),
pub phase: GesturePhase,
pub press_origin: Point,
pub offset_at_press: Point,
pub last_point: Point,
pub velocity: (f32, f32),
pub last_sample_point: Point,
pub last_sample_ms: u64,
pub spring_target: Point,
pub max_offset: Point,
pub content: Size,
pub viewport: Size,
}Expand description
Cross-frame scroll/gesture/velocity state owned by the host screen.
Copy so the scroll_core engine can take it by value (see this module’s
header for why).
Fields§
§offset: PointCurrent committed scroll offset in pixels (subtracted from children).
accum: (f32, f32)Sub-pixel integrator for smooth fling/spring motion.
phase: GesturePhaseCurrent gesture/animation phase.
press_origin: PointScreen point where the active press began.
offset_at_press: Pointoffset captured at the moment of press (drag is relative to this).
last_point: PointMost recent point seen during the gesture.
velocity: (f32, f32)Current velocity in px/s, sampled at release.
last_sample_point: PointPoint of the last velocity sample.
last_sample_ms: u64Millisecond timestamp of the last velocity sample.
spring_target: PointSpring destination while GesturePhase::Springing.
max_offset: PointCached maximum scrollable offset (max(content - viewport, 0)).
content: SizeCached content size from the last layout pass.
viewport: SizeCached viewport size from the last layout pass.
Implementations§
Source§impl ScrollState
impl ScrollState
Sourcepub fn is_animating(&self) -> bool
pub fn is_animating(&self) -> bool
True while coasting (GesturePhase::Flinging) or settling
(GesturePhase::Springing) — i.e. the host should keep ticking.
Sourcepub fn clamp_offset(&self, offset: Point) -> Point
pub fn clamp_offset(&self, offset: Point) -> Point
Clamp offset into the valid [0, max_offset] range on both axes.
Sourcepub fn rubber_band(&self, offset: Point) -> Point
pub fn rubber_band(&self, offset: Point) -> Point
Apply rubber-band resistance to a raw drag offset: any overshoot past
[0, max_offset] is compressed by resist(o, dim) = o*dim/(dim+o*C).
Sourcepub fn nearest_snap(
&self,
offset: Point,
snap: SnapMode,
snap_lines: &[i32],
) -> Point
pub fn nearest_snap( &self, offset: Point, snap: SnapMode, snap_lines: &[i32], ) -> Point
Nearest snap line to offset among lines, clamped to range. Empty
lines (or SnapMode::None) returns the clamped offset.
Trait Implementations§
Source§impl Clone for ScrollState
impl Clone for ScrollState
Source§fn clone(&self) -> ScrollState
fn clone(&self) -> ScrollState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more