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: f64The 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
impl EdgeDraggingAutoScroller
Sourcepub fn new(
app: &mut App,
scrollable: Handle<ScrollableState>,
on_scroll_view_scrolled: Option<Listener>,
velocity_scalar: f64,
) -> Ref<EdgeDraggingAutoScroller>
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.
Sourcepub fn scrolling(self: Handle<Self>, app: &App) -> bool
pub fn scrolling(self: Handle<Self>, app: &App) -> bool
Whether the auto scroll is in progress.
Sourcepub fn start_auto_scroll_if_necessary(
self: Handle<Self>,
app: &mut App,
drag_target: Rect,
)
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.
Sourcepub fn stop_auto_scroll(self: Handle<Self>, app: &mut App)
pub fn stop_auto_scroll(self: Handle<Self>, app: &mut App)
Stop any ongoing auto scrolling.