Skip to main content

Crate nativeview_scroll_physics

Crate nativeview_scroll_physics 

Source
Expand description

Pluggable, zero-allocation scroll physics engine, composable Flutter-style ScrollBehavior decorators, platform presets (ScrollPhysicsProfile / PlatformScrollPhysics), and sparse per-container ScrollPhysics (nv.scroll_physics) overrides.

Backed directly by nativeview-physics closed-form solvers (DecaySpec, RubberBandSpec, SmoothWheelSpec, SpringSpec/SpringState, VelocityTracker) with zero duplicated math.

Structs§

ActiveScrollAxis
Per-axis closed-form scroll physics state (Copy, zero heap fields).
ActiveScrollEntry
Active scroll physics record for one animated/stretched Scroll container (Copy, 0 heap).
ClampBoundary
Hard-clamped scroll boundary: stops at [0..=max] with zero rubber-band overscroll.
ComposedScrollBehavior
Zero-overhead static combinator stacking independent boundary, fling, snap, wheel, and spring return decorators.
DetentSnap
Zero-allocation inline snap detents ([f32; 8] + len: u8) for bottom sheets, drawers, and irregular card carousels.
ExplicitRubberBandBoundary
Explicit-request (opt-in) rubber-band boundary (Windows/Linux desktop default): hard-clamps plain containers while honoring Scroll::bounce(true) and ScrollBoundaryMode::Bounce.
ExponentialDecayFling
Exponentially decelerating inertial fling backed by DecaySpec.
FixedExtentSnap
Snaps to regular fixed-extent item offsets (leading_offset + k * item_extent).
FreeScroll
Free scrolling with no snap points.
InstantWheel
Immediate deterministic discrete wheel detents with zero smoothing animation.
NoFling
Disables post-release inertial fling momentum.
PageSnap
Snaps to integer multiples of the container’s viewport extent (carousel / pager semantics).
PooledScrollPhysics
RubberBandBoundary
Elastic Apple/Android-style rubber-band overscroll boundary enabled by default.
ScrollPhysics
Optional per-container scroll physics overrides (nv.scroll_physics, sparse, 0 B when absent).
SmoothWheel
Exponentially smoothed discrete wheel detents backed by SmoothWheelSpec.
SnapQuery
Read-only release kinematics passed to SnapPhysics::snap_target.
SpringReturn
Return & snap spring specification wrapping SpringSpec.

Enums§

AxisPhase
Lifecycle phase of one scroll container axis inside crate::PooledScrollPhysics.
ScrollBoundaryMode
Per-container boundary resistance override for ScrollPhysics.
ScrollPhysicsProfile
Platform-tuned scroll physics profile (deceleration, spring frequency, wheel line step, smooth-wheel time constant, and default rubber-band elasticity).
ScrollSnapMode
Per-container snap-point mode override for ScrollPhysics.

Constants§

MAX_ACTIVE_SCROLL_ENTRIES
Upper bound on concurrently active/stretched scroll containers tracked in PooledScrollPhysics.
MAX_DETENT_STOPS
Maximum inline snap detents supported by DetentSnap with zero heap allocation.

Traits§

BoundaryPhysics
Boundary overscroll resistance policy.
FlingPhysics
Inertial fling momentum policy after trackpad/touch release.
ScrollBehavior
Unified scroll behavior contract consumed by PooledScrollPhysics.
SnapPhysics
Post-release snap-point targeting policy.
WheelPhysics
Discrete mouse-wheel easing policy.

Functions§

install_platform_scroll_physics
Convenience helper installing PlatformScrollPhysics::platform_default() onto scene.
rubber_band_forward
Apple asymptote rubber-band drag resistance: sign(raw) * c*|raw|*D / (D + c*|raw|).
rubber_band_inverse
Exact inverse of rubber_band_forward for smooth drag unwinding.

Type Aliases§

PlatformScrollPhysics
Platform-preset PooledScrollPhysics engine ready to install onto LaidOutScene, SkiaBackend, or DesktopSession.