Skip to main content

ScrollDragController

Struct ScrollDragController 

Source
pub struct ScrollDragController {
    pub on_drag_canceled: Option<Listener>,
    pub carried_velocity: Option<f64>,
    pub motion_start_distance_threshold: Option<f64>,
    /* private fields */
}
Expand description

Scrolls a scroll view as the user drags their finger across the screen.

See also:

  • DragScrollActivity, which is the activity the scroll view performs while a drag is underway.

Fields§

§on_drag_canceled: Option<Listener>

Called when dispose is called.

§carried_velocity: Option<f64>

Velocity that was present from a previous ScrollActivity when this drag began.

§motion_start_distance_threshold: Option<f64>

Amount of pixels in either direction the drag has to move by to start scroll movement again after each time scrolling came to a stop.

Implementations§

Source§

impl ScrollDragController

Source

pub const MOMENTUM_RETAIN_STATIONARY_DURATION_THRESHOLD: Duration

Maximum amount of time interval the drag can have consecutive stationary pointer update events before losing the momentum carried from a previous scroll activity.

Source

pub const MOMENTUM_RETAIN_VELOCITY_THRESHOLD_FACTOR: f64 = 0.5

The minimum amount of velocity needed to apply the carried_velocity at the end of a drag. Expressed as a factor. For example with a carried_velocity of 2000, we will need a velocity of at least 1000 to apply the carried_velocity as well. If the velocity does not meet the threshold, the carried_velocity is lost. Decided by fair eyeballing with the scroll_overlay platform test.

Source

pub const MOTION_STOPPED_DURATION_THRESHOLD: Duration

Maximum amount of time interval the drag can have consecutive stationary pointer update events before needing to break the motion_start_distance_threshold to start motion again.

Source

pub fn new( app: &mut App, delegate: AnyScrollActivityDelegate, details: DragStartDetails, on_drag_canceled: Option<Listener>, carried_velocity: Option<f64>, motion_start_distance_threshold: Option<f64>, ) -> Ref<ScrollDragController>

Creates an object that scrolls a scroll view as the user drags their finger across the screen.

Source

pub fn delegate(self: Handle<Self>, app: &App) -> AnyScrollActivityDelegate

The object that will actuate the scroll view as the user drags.

Source

pub fn kind(self: Handle<Self>, app: &App) -> Option<PointerDeviceKind>

The type of input device driving the drag; Dart’s _kind.

Source

pub fn last_details(self: Handle<Self>, app: &App) -> Option<&LastDragDetails>

The most recently observed DragStartDetails, DragUpdateDetails, or DragEndDetails object.

Source

pub fn update_delegate( self: Handle<Self>, app: &mut App, value: AnyScrollActivityDelegate, )

Updates the controller’s link to the ScrollActivityDelegate.

This should only be called when a controller is being moved from a defunct (or about-to-be defunct) ScrollActivityDelegate object to a new one.

Source

pub fn dispose(self: Handle<Self>, app: &mut App)

Called by the delegate when it is no longer sending events to this object.

Source

pub fn describe(self: Handle<Self>) -> String

Dart’s toString, which reads the arena and so cannot be std::fmt::Debug.

Trait Implementations§

Source§

impl DragObject for ScrollDragController

Source§

fn update(self: Handle<Self>, app: &mut App, details: DragUpdateDetails)

Source§

fn end(self: Handle<Self>, app: &mut App, details: DragEndDetails)

Source§

fn cancel(self: Handle<Self>, app: &mut App)

Auto Trait Implementations§

§

impl !RefUnwindSafe for ScrollDragController

§

impl !Send for ScrollDragController

§

impl !Sync for ScrollDragController

§

impl !UnwindSafe for ScrollDragController

§

impl Forget for ScrollDragController

§

impl Freeze for ScrollDragController
where NonZero<u32>: Freeze, &'static ScrollActivityDelegateVTable: Freeze, *const RcInner<dyn Fn(&mut App)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App)>>: Freeze, *const (): Freeze,

§

impl Move for ScrollDragController

§

impl Unpin for ScrollDragController
where NonZero<u32>: Unpin, &'static ScrollActivityDelegateVTable: Unpin, Rc<dyn Fn(&mut App)>: Unpin, *const (): Unpin,

§

impl UnsafeUnpin for ScrollDragController
where NonZeroU32Inner: UnsafeUnpin, &'static ScrollActivityDelegateVTable: UnsafeUnpin, *const RcInner<dyn Fn(&mut App)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App)>>: UnsafeUnpin, *const (): UnsafeUnpin,

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>