pub struct ScrollBehavior { /* private fields */ }Expand description
How the scrollables under it behave, from the platform it follows.
Two starting points, as in the reference: ScrollBehavior::new, the base, which
follows default_target_platform, and
ScrollBehavior::material, the one an application installs, which follows
Theme::platform. Each can be changed with the with_ methods, the reference’s
copyWith: a behaviour with its scrollbars or its overscroll indicator turned off, with
physics of its own, or following another platform.
The answers, platform by platform, are the reference’s:
| physics | scrollbars | overscroll | fling | |
|---|---|---|---|---|
| Android | clamping | none | stretch (base: glow) | regression |
| Fuchsia | clamping | none | glow | regression |
| iOS | bouncing | none | none | recent average |
| macOS | bouncing, fast | shown | none | recent average, desktop |
| Linux, Windows | clamping | shown | none | regression |
Implementations§
Source§impl ScrollBehavior
impl ScrollBehavior
Sourcepub const fn new() -> Self
pub const fn new() -> Self
The base behaviour: it follows the platform the application runs on
(default_target_platform), and shows a glow
past the edge on Android and Fuchsia. What ScrollConfiguration::of answers where
nothing was installed.
Sourcepub const fn material() -> Self
pub const fn material() -> Self
The application’s behaviour: it follows the theme’s platform
(Theme::platform), and stretches the content past the edge on Android. What an
application installs unless it says otherwise
(Application::scroll_behavior).
Sourcepub const fn with_scrollbars(self, scrollbars: bool) -> Self
pub const fn with_scrollbars(self, scrollbars: bool) -> Self
The same behaviour, with its scrollbars on or off. Off, none is drawn on any platform; on, the platform decides.
Sourcepub const fn with_overscroll(self, overscroll: bool) -> Self
pub const fn with_overscroll(self, overscroll: bool) -> Self
The same behaviour, with its overscroll indicator on or off. Off, nothing is shown past an edge on any platform; on, the platform decides.
Sourcepub const fn with_physics(self, physics: ScrollPhysics) -> Self
pub const fn with_physics(self, physics: ScrollPhysics) -> Self
The same behaviour, with these physics on every platform.
Sourcepub const fn with_platform(self, platform: TargetPlatform) -> Self
pub const fn with_platform(self, platform: TargetPlatform) -> Self
The same behaviour, following platform instead of the one it would have followed.
Sourcepub fn platform(&self, theme: &Theme) -> TargetPlatform
pub fn platform(&self, theme: &Theme) -> TargetPlatform
The platform this behaviour follows under theme: the one it was given, else the
theme’s for the application’s behaviour, else the one the application runs on.
Sourcepub fn scroll_physics(&self, theme: &Theme) -> ScrollPhysics
pub fn scroll_physics(&self, theme: &Theme) -> ScrollPhysics
The physics a scrollable under this behaviour starts from: bouncing on iOS, bouncing with a faster stop on macOS, clamping elsewhere — unless the behaviour was given its own. A scrollable’s own physics take precedence over these.
Sourcepub fn scrollbars(&self, theme: &Theme) -> Scrollbars
pub fn scrollbars(&self, theme: &Theme) -> Scrollbars
Whether a vertical scrollable under this behaviour draws a scrollbar: on Linux, macOS and Windows, where a pointer needs one to find its way; not on a touch screen, where a finger already knows where it is on the page.
Sourcepub fn overscroll_indicator(&self, theme: &Theme) -> Option<OverscrollIndicator>
pub fn overscroll_indicator(&self, theme: &Theme) -> Option<OverscrollIndicator>
What a scrollable under this behaviour shows when it is pulled past an edge it will
not move beyond, or None for nothing: the stretch on Android under the
application’s behaviour, a glow on Android under the base one and on Fuchsia under
both, nothing on iOS, Linux, macOS and Windows.
Sourcepub fn velocity_tracker(&self, theme: &Theme) -> VelocityTracker
pub fn velocity_tracker(&self, theme: &Theme) -> VelocityTracker
How a fling under this behaviour is read from the finger’s last moves: a weighted average of the most recent on iOS and macOS (each with its own weights), a fitted curve elsewhere.
Trait Implementations§
Source§impl Clone for ScrollBehavior
impl Clone for ScrollBehavior
impl Copy for ScrollBehavior
Source§impl Debug for ScrollBehavior
impl Debug for ScrollBehavior
Source§impl Default for ScrollBehavior
impl Default for ScrollBehavior
Source§fn default() -> Self
fn default() -> Self
The base behaviour, ScrollBehavior::new.