Skip to main content

nativeview_scroll_physics/
lib.rs

1//! Pluggable, zero-allocation scroll physics engine, composable Flutter-style [`ScrollBehavior`]
2//! decorators, platform presets ([`ScrollPhysicsProfile`] / [`PlatformScrollPhysics`]), and
3//! sparse per-container [`ScrollPhysics`] (`nv.scroll_physics`) overrides.
4//!
5//! Backed directly by `nativeview-physics` closed-form solvers (`DecaySpec`, `RubberBandSpec`,
6//! `SmoothWheelSpec`, `SpringSpec`/`SpringState`, `VelocityTracker`) with zero duplicated math.
7
8#![cfg_attr(doctest, doc = include_str!("../README.md"))]
9
10mod axis;
11mod behavior;
12mod pool;
13mod profile;
14mod resolve;
15mod table;
16
17use nativeview_layout::{LaidOutScene, StoreLayoutEngine};
18
19pub use axis::{ActiveScrollAxis, AxisPhase};
20pub use behavior::{
21    BoundaryPhysics, ClampBoundary, ComposedScrollBehavior, DetentSnap, ExponentialDecayFling,
22    FixedExtentSnap, FlingPhysics, FreeScroll, InstantWheel, MAX_DETENT_STOPS, NoFling,
23    ExplicitRubberBandBoundary, PageSnap, RubberBandBoundary, ScrollBehavior, SmoothWheel,
24    SnapPhysics, SnapQuery, SpringReturn, WheelPhysics,
25};
26pub use pool::{ActiveScrollEntry, MAX_ACTIVE_SCROLL_ENTRIES, PooledScrollPhysics};
27pub use profile::{
28    PlatformScrollPhysics, ScrollPhysicsProfile, rubber_band_forward, rubber_band_inverse,
29};
30pub use table::{ScrollBoundaryMode, ScrollPhysics, ScrollSnapMode};
31
32/// Convenience helper installing [`PlatformScrollPhysics::platform_default()`] onto `scene`.
33#[inline]
34pub fn install_platform_scroll_physics<L: StoreLayoutEngine>(scene: &mut LaidOutScene<L>) {
35    scene.set_scroll_physics(Box::new(PlatformScrollPhysics::platform_default()));
36}