pub struct DraggableState { /* private fields */ }Expand description
Drag position and progress for one control.
Cloning shares the state, so a scope can hold a handle and the modifier can hold another without either owning the truth.
Implementations§
Source§impl DraggableState
impl DraggableState
Sourcepub fn new(on_delta: impl Fn(f32) + 'static) -> Self
pub fn new(on_delta: impl Fn(f32) + 'static) -> Self
Creates a drag state delivering deltas to on_delta.
Prefer rememberDraggableState inside a composition; this is for
callers that own the state themselves.
Sourcepub fn update_handler(&self, on_delta: impl Fn(f32) + 'static)
pub fn update_handler(&self, on_delta: impl Fn(f32) + 'static)
Replaces the delta handler.
A composition calls this every recomposition so the handler closes over the current values rather than the ones the first composition captured.
Sourcepub fn is_dragging(&self) -> bool
pub fn is_dragging(&self) -> bool
Whether a drag is in flight. Reactive: a composable that reads it recomposes when the drag starts and when it ends, and not per frame in between.
Sourcepub fn dragging(&self) -> State<bool>
pub fn dragging(&self) -> State<bool>
is_dragging as a state a scope can hand around.
Trait Implementations§
Source§impl Clone for DraggableState
impl Clone for DraggableState
Source§fn clone(&self) -> DraggableState
fn clone(&self) -> DraggableState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl PartialEq for DraggableState
impl PartialEq for DraggableState
Auto Trait Implementations§
impl !RefUnwindSafe for DraggableState
impl !Send for DraggableState
impl !Sync for DraggableState
impl !UnwindSafe for DraggableState
impl Freeze for DraggableState
impl Unpin for DraggableState
impl UnsafeUnpin for DraggableState
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