pub struct RangeMaintainingScrollPhysics {
pub parent: Option<ScrollPhysicsRef>,
}Expand description
Scroll physics that attempt to keep the scroll position in range when the contents change dimensions suddenly.
This attempts to maintain the amount of overscroll or underscroll already present, if the scroll position is already out of range and the extents have decreased, meaning that some content was removed. The reason for this condition is that when new content is added, keeping the same overscroll would mean that instead of showing it to the user, all of it is being skipped by jumping right to the max extent.
If the scroll activity is animating the scroll position, sudden changes to the scroll dimensions are allowed to happen (so as to prevent animations from jumping back and forth between in-range and out-of-range values).
These physics should be combined with other scroll physics, e.g.
BouncingScrollPhysics or ClampingScrollPhysics, to obtain a complete
description of typical scroll physics. See ScrollPhysics::apply_to.
§Implementation details
Specifically, these physics perform two adjustments.
The first is to maintain overscroll when the position is out of range.
The second is to enforce the boundary when the position is in range.
If the current velocity is non-zero, neither adjustment is made. The assumption is that there is an ongoing animation and therefore further changing the scroll position would disrupt the experience.
If the extents haven’t changed, then the overscroll adjustment is
not made. The assumption is that if the position is overscrolled,
it is intentional, otherwise the position could not have reached
that position. (Consider ClampingScrollPhysics vs
BouncingScrollPhysics for example.)
If the position itself changed since the last animation frame, then the overscroll is not maintained. The assumption is similar to the previous case: the position would not have been placed out of range unless it was intentional.
In addition, if the position changed and the boundaries were and still are finite, then the boundary isn’t enforced either, for the same reason. However, if any of the boundaries were or are now infinite, the boundary is enforced, on the assumption that infinite boundaries indicate a lazy-loading scroll view, which cannot enforce boundaries while the full list has not loaded.
If the range was out of range, then the boundary is not enforced even if the range is not maintained. If the range is maintained, then the distance between the old position and the old boundary is applied to the new boundary to obtain the new position.
If the range was in range, and the boundary is to be enforced, then the new position is obtained by deferring to the other physics, if any, and then clamped to the new range.
Fields§
§parent: Option<ScrollPhysicsRef>Implementations§
Source§impl RangeMaintainingScrollPhysics
impl RangeMaintainingScrollPhysics
Sourcepub fn new() -> RangeMaintainingScrollPhysics
pub fn new() -> RangeMaintainingScrollPhysics
Creates scroll physics that maintain the scroll position in range.
Sourcepub fn with_parent(
self,
parent: ScrollPhysicsRef,
) -> RangeMaintainingScrollPhysics
pub fn with_parent( self, parent: ScrollPhysicsRef, ) -> RangeMaintainingScrollPhysics
Dart RangeMaintainingScrollPhysics(parent:).
Trait Implementations§
Source§impl ScrollPhysics for RangeMaintainingScrollPhysics
impl ScrollPhysics for RangeMaintainingScrollPhysics
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 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 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 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 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 spring(&self) -> SpringDescription
fn spring(&self) -> SpringDescription
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 min_fling_velocity(&self) -> f64
fn min_fling_velocity(&self) -> f64
Source§fn max_fling_velocity(&self) -> f64
fn max_fling_velocity(&self) -> f64
Source§fn carried_momentum(&self, existing_velocity: f64) -> f64
fn carried_momentum(&self, existing_velocity: f64) -> f64
Source§fn drag_start_distance_motion_threshold(&self) -> Option<f64>
fn drag_start_distance_motion_threshold(&self) -> Option<f64>
Source§fn allow_implicit_scrolling(&self) -> bool
fn allow_implicit_scrolling(&self) -> bool
RenderObject.showOnScreen. Read more