Skip to main content

EdgeDraggingAutoScroller

Struct EdgeDraggingAutoScroller 

Source
pub struct EdgeDraggingAutoScroller {
    pub scrollable: Handle<ScrollableState>,
    pub on_scroll_view_scrolled: Option<Listener>,
    pub velocity_scalar: f64,
    /* private fields */
}
Expand description

An auto scroller that scrolls the scrollable if a drag gesture drags close to its edge.

The scroll velocity is controlled by the velocity_scalar:

velocity = (distance of overscroll) * velocity_scalar.

Fields§

§scrollable: Handle<ScrollableState>

The Scrollable this auto scroller is scrolling.

§on_scroll_view_scrolled: Option<Listener>

Called when a scroll view is scrolled.

The scroll view may be scrolled multiple times in a row until the drag target no longer triggers the auto scroll. This callback will be called in between each scroll.

§velocity_scalar: f64

The velocity scalar per pixel over scroll.

It represents how the velocity scale with the over scroll distance. The auto-scroll velocity = (distance of overscroll) * velocity_scalar.

Implementations§

Source§

impl EdgeDraggingAutoScroller

Source

pub fn new( app: &mut App, scrollable: Handle<ScrollableState>, on_scroll_view_scrolled: Option<Listener>, velocity_scalar: f64, ) -> Ref<EdgeDraggingAutoScroller>

Creates a auto scroller that scrolls the scrollable.

Source

pub fn scrolling(self: Handle<Self>, app: &App) -> bool

Whether the auto scroll is in progress.

Source

pub fn start_auto_scroll_if_necessary( self: Handle<Self>, app: &mut App, drag_target: Rect, )

Starts the auto scroll if the drag_target is close to the edge.

The scroll starts to scroll the scrollable if the target rect is close to the edge of the scrollable; otherwise, it remains stationary.

If the scrollable is already scrolling, calling this method updates the previous drag target to the new value and continues scrolling if necessary.

If the scrollable’s ScrollableState::resolved_physics refuses user-driven scrolling (for example NeverScrollableScrollPhysics), no auto scroll is started and any in-flight auto scroll is stopped.

Source

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

Stop any ongoing auto scrolling.

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>