pub struct NestedScrollConnection {
pub on_pre_scroll: Option<PreScrollFn>,
pub on_post_scroll: Option<PostScrollFn>,
pub on_pre_fling: Option<PreScrollFn>,
pub on_post_fling: Option<PostScrollFn>,
}Fields§
§on_pre_scroll: Option<PreScrollFn>§on_post_scroll: Option<PostScrollFn>§on_pre_fling: Option<PreScrollFn>§on_post_fling: Option<PostScrollFn>Implementations§
Source§impl NestedScrollConnection
impl NestedScrollConnection
pub fn new() -> Self
pub fn on_pre_scroll( self, f: impl Fn(Vec2, NestedScrollSource) -> Vec2 + 'static, ) -> Self
pub fn on_post_scroll( self, f: impl Fn(Vec2, Vec2, NestedScrollSource) -> Vec2 + 'static, ) -> Self
pub fn on_pre_fling( self, f: impl Fn(Vec2, NestedScrollSource) -> Vec2 + 'static, ) -> Self
pub fn on_post_fling( self, f: impl Fn(Vec2, Vec2, NestedScrollSource) -> Vec2 + 'static, ) -> Self
pub fn dispatch_pre_scroll( &self, available: Vec2, source: NestedScrollSource, ) -> Vec2
pub fn dispatch_post_scroll( &self, consumed: Vec2, available: Vec2, source: NestedScrollSource, ) -> Vec2
Sourcepub fn dispatch_pre_fling(
&self,
available: Vec2,
source: NestedScrollSource,
) -> Vec2
pub fn dispatch_pre_fling( &self, available: Vec2, source: NestedScrollSource, ) -> Vec2
Offer a fling to ancestors before this scrollable consumes it. Pair
with dispatch_post_fling to coordinate who actually starts a fling.
Sourcepub fn dispatch_post_fling(
&self,
consumed: Vec2,
available: Vec2,
source: NestedScrollSource,
) -> Vec2
pub fn dispatch_post_fling( &self, consumed: Vec2, available: Vec2, source: NestedScrollSource, ) -> Vec2
Hand a fling that clamped at a boundary to ancestors, so a parent can keep coasting with the leftover velocity. The intended chaining pattern is for the parent to seed its own physics from the velocity it receives:
ⓘ
let connection = NestedScrollConnection::new().on_post_fling(
|_consumed, available, _source| {
parent_state.fling(available);
available
},
);
child_state.set_nested_scroll_parent(connection);ScrollState::connection() already wires this up, so the common
parent/child case needs no extra code.
pub fn then(&self, further: &Self) -> Self
Trait Implementations§
Source§impl Clone for NestedScrollConnection
impl Clone for NestedScrollConnection
Source§impl Debug for NestedScrollConnection
impl Debug for NestedScrollConnection
Auto Trait Implementations§
impl !RefUnwindSafe for NestedScrollConnection
impl !Send for NestedScrollConnection
impl !Sync for NestedScrollConnection
impl !UnwindSafe for NestedScrollConnection
impl Forget for NestedScrollConnection
impl Freeze for NestedScrollConnection
impl Move for NestedScrollConnection
impl Unpin for NestedScrollConnection
impl UnsafeUnpin for NestedScrollConnection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more