Skip to main content

RangeMaintainingScrollPhysics

Struct RangeMaintainingScrollPhysics 

Source
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

Source

pub fn new() -> RangeMaintainingScrollPhysics

Creates scroll physics that maintain the scroll position in range.

Source

pub fn with_parent( self, parent: ScrollPhysicsRef, ) -> RangeMaintainingScrollPhysics

Dart RangeMaintainingScrollPhysics(parent:).

Trait Implementations§

Source§

impl Debug for RangeMaintainingScrollPhysics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RangeMaintainingScrollPhysics

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl ScrollPhysics for RangeMaintainingScrollPhysics

Source§

fn as_any(&self) -> &dyn Any

The value behind the erased physics, for Dart’s physics.runtimeType — which ScrollableState._shouldUpdatePosition compares along the whole parent chain.
Source§

fn parent(&self) -> Option<&ScrollPhysicsRef>

If non-null, determines the default behavior for each method. Read more
Source§

fn apply_to(&self, ancestor: Option<ScrollPhysicsRef>) -> ScrollPhysicsRef

Combines this ScrollPhysics instance with the given physics. Read more
Source§

fn adjust_position_for_new_dimensions( &self, old_position: &dyn ScrollMetrics, new_position: &dyn ScrollMetrics, is_scrolling: bool, velocity: f64, ) -> f64

Describes what the scroll position should be given new viewport dimensions. Read more
Source§

fn apply_physics_to_user_offset( &self, position: &dyn ScrollMetrics, offset: f64, ) -> f64

Used by 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 more
Source§

fn should_accept_user_offset(&self, position: &dyn ScrollMetrics) -> bool

Whether the scrollable should let the user adjust the scroll offset, for example by dragging. If allow_user_scrolling is false, the scrollable will never allow user input to change the scroll position. Read more
Source§

fn allow_selection_edge_scrolling(&self) -> bool

Whether a viewport may scroll to reveal more content when a selection gesture extends past the visible area, i.e. the viewport’s edge. Read more
Source§

fn recommend_deferred_loading( &self, app: &mut App, velocity: f64, metrics: &dyn ScrollMetrics, context: BuildContext, ) -> bool

Provides a heuristic to determine if expensive frame-bound tasks should be deferred. Read more
Source§

fn apply_boundary_conditions( &self, position: &dyn ScrollMetrics, value: f64, ) -> f64

Determines the overscroll by applying the boundary conditions. Read more
Source§

fn create_ballistic_simulation( &self, position: &dyn ScrollMetrics, velocity: f64, ) -> Option<Box<dyn Simulation>>

Returns a simulation for ballistic scrolling starting from the given position with the given velocity. Read more
Source§

fn spring(&self) -> SpringDescription

The spring to use for ballistic simulations.
Source§

fn tolerance_for(&self, metrics: &dyn ScrollMetrics) -> Tolerance

The tolerance to use for ballistic simulations.
Source§

fn min_fling_distance(&self) -> f64

The minimum distance an input pointer drag must have moved to be considered a scroll fling gesture. Read more
Source§

fn min_fling_velocity(&self) -> f64

The minimum velocity for an input pointer drag to be considered a scroll fling. Read more
Source§

fn max_fling_velocity(&self) -> f64

Scroll fling velocity magnitudes will be clamped to this value.
Source§

fn carried_momentum(&self, existing_velocity: f64) -> f64

Returns the velocity carried on repeated flings. Read more
Source§

fn drag_start_distance_motion_threshold(&self) -> Option<f64>

The minimum amount of pixel distance drags must move by to start motion the first time or after each time the drag motion stopped. Read more
Source§

fn allow_implicit_scrolling(&self) -> bool

Whether a viewport is allowed to change its scroll position implicitly in response to a call to RenderObject.showOnScreen. Read more
Source§

fn allow_user_scrolling(&self) -> bool

Whether a viewport is allowed to change the scroll position as the result of user input.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>