pub struct BouncingScrollPhysics {
pub deceleration_rate: ScrollDecelerationRate,
pub parent: Option<ScrollPhysicsRef>,
}Expand description
Scroll physics for environments that allow the scroll offset to go beyond the bounds of the content, but then bounce the content back to the edge of those bounds.
This is the behavior typically seen on iOS.
BouncingScrollPhysics by itself will not create an overscroll effect if
the contents of the scroll view do not extend beyond the size of the
viewport. To create the overscroll and bounce effect regardless of the
length of your scroll view, combine with AlwaysScrollableScrollPhysics.
See also:
ScrollConfiguration, which uses this to provide the default scroll behavior on iOS.ClampingScrollPhysics, which is the analogous physics for Android’s clamping behavior.ScrollPhysics, for more examples of combiningScrollPhysicsobjects of different types to get the desired scroll physics.
Fields§
§deceleration_rate: ScrollDecelerationRateUsed to determine parameters for friction simulations.
parent: Option<ScrollPhysicsRef>Implementations§
Source§impl BouncingScrollPhysics
impl BouncingScrollPhysics
Sourcepub fn new() -> BouncingScrollPhysics
pub fn new() -> BouncingScrollPhysics
Creates scroll physics that bounce back from the edge.
Sourcepub fn with_deceleration_rate(
self,
deceleration_rate: ScrollDecelerationRate,
) -> BouncingScrollPhysics
pub fn with_deceleration_rate( self, deceleration_rate: ScrollDecelerationRate, ) -> BouncingScrollPhysics
Dart BouncingScrollPhysics(decelerationRate:).
Sourcepub fn with_parent(self, parent: ScrollPhysicsRef) -> BouncingScrollPhysics
pub fn with_parent(self, parent: ScrollPhysicsRef) -> BouncingScrollPhysics
Dart BouncingScrollPhysics(parent:).
Sourcepub fn friction_factor(&self, overscroll_fraction: f64) -> f64
pub fn friction_factor(&self, overscroll_fraction: f64) -> f64
The multiple applied to overscroll to make it appear that scrolling past the edge of the scrollable contents is harder than scrolling within bounds. This is done by reducing the ratio of the scroll effect output vs the scroll gesture input.
This factor starts at 0.52 for ScrollDecelerationRate::Normal and 0.26 for
ScrollDecelerationRate::Fast.
The overscroll_fraction represents how far past the edge the user has
dragged, where 0.0 means no overscroll. As this value increases, the
friction factor decreases quadratically, making further overscroll harder.
Trait Implementations§
Source§impl Debug for BouncingScrollPhysics
impl Debug for BouncingScrollPhysics
Source§impl Default for BouncingScrollPhysics
impl Default for BouncingScrollPhysics
Source§fn default() -> BouncingScrollPhysics
fn default() -> BouncingScrollPhysics
Source§impl ScrollPhysics for BouncingScrollPhysics
impl ScrollPhysics for BouncingScrollPhysics
Source§fn carried_momentum(&self, existing_velocity: f64) -> f64
fn carried_momentum(&self, existing_velocity: f64) -> f64
Momentum build-up function that mimics iOS’s scroll speed increase with repeated flings.
The velocity of the last fling is not an important factor. Existing speed and (related) time since last fling are factors for the velocity transfer calculations.
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
physics.runtimeType — which
ScrollableState._shouldUpdatePosition compares along the whole parent chain.Source§fn parent(&self) -> Option<&ScrollPhysicsRef>
fn parent(&self) -> Option<&ScrollPhysicsRef>
Source§fn apply_to(&self, ancestor: Option<ScrollPhysicsRef>) -> ScrollPhysicsRef
fn apply_to(&self, ancestor: Option<ScrollPhysicsRef>) -> ScrollPhysicsRef
ScrollPhysics instance with the given physics. Read moreSource§fn apply_physics_to_user_offset(
&self,
position: &dyn ScrollMetrics,
offset: f64,
) -> f64
fn apply_physics_to_user_offset( &self, position: &dyn ScrollMetrics, offset: f64, ) -> f64
DragScrollActivity and other user-driven activities to convert
an offset in logical pixels as provided by the DragUpdateDetails into a
delta to apply (subtract from the current position) using
ScrollActivityDelegate.setPixels. Read moreSource§fn apply_boundary_conditions(
&self,
_position: &dyn ScrollMetrics,
_value: f64,
) -> f64
fn apply_boundary_conditions( &self, _position: &dyn ScrollMetrics, _value: f64, ) -> f64
Source§fn create_ballistic_simulation(
&self,
position: &dyn ScrollMetrics,
velocity: f64,
) -> Option<Box<dyn Simulation>>
fn create_ballistic_simulation( &self, position: &dyn ScrollMetrics, velocity: f64, ) -> Option<Box<dyn Simulation>>
Source§fn min_fling_velocity(&self) -> f64
fn min_fling_velocity(&self) -> f64
Source§fn drag_start_distance_motion_threshold(&self) -> Option<f64>
fn drag_start_distance_motion_threshold(&self) -> Option<f64>
Source§fn max_fling_velocity(&self) -> f64
fn max_fling_velocity(&self) -> f64
Source§fn spring(&self) -> SpringDescription
fn spring(&self) -> SpringDescription
Source§fn should_accept_user_offset(&self, position: &dyn ScrollMetrics) -> bool
fn should_accept_user_offset(&self, position: &dyn ScrollMetrics) -> bool
allow_user_scrolling is
false, the scrollable will never allow user input to change the scroll position. Read moreSource§fn allow_selection_edge_scrolling(&self) -> bool
fn allow_selection_edge_scrolling(&self) -> bool
Source§fn recommend_deferred_loading(
&self,
app: &mut App,
velocity: f64,
metrics: &dyn ScrollMetrics,
context: BuildContext,
) -> bool
fn recommend_deferred_loading( &self, app: &mut App, velocity: f64, metrics: &dyn ScrollMetrics, context: BuildContext, ) -> bool
Source§fn adjust_position_for_new_dimensions(
&self,
old_position: &dyn ScrollMetrics,
new_position: &dyn ScrollMetrics,
is_scrolling: bool,
velocity: f64,
) -> f64
fn adjust_position_for_new_dimensions( &self, old_position: &dyn ScrollMetrics, new_position: &dyn ScrollMetrics, is_scrolling: bool, velocity: f64, ) -> f64
Source§fn tolerance_for(&self, metrics: &dyn ScrollMetrics) -> Tolerance
fn tolerance_for(&self, metrics: &dyn ScrollMetrics) -> Tolerance
Source§fn min_fling_distance(&self) -> f64
fn min_fling_distance(&self) -> f64
Source§fn allow_implicit_scrolling(&self) -> bool
fn allow_implicit_scrolling(&self) -> bool
RenderObject.showOnScreen. Read more