pub struct DragState { /* private fields */ }Expand description
Pure-math drag state tracker.
Tracks pointer position, computes velocity via exponential moving average, and applies constraints. No DOM dependency.
Implementations§
Source§impl DragState
impl DragState
Sourcepub fn with_constraints(self, constraints: DragConstraints) -> Self
pub fn with_constraints(self, constraints: DragConstraints) -> Self
Set constraints (builder-style).
Sourcepub fn with_position(self, position: [f32; 2]) -> Self
pub fn with_position(self, position: [f32; 2]) -> Self
Set initial position (builder-style).
Sourcepub fn on_pointer_down(&mut self, x: f32, y: f32)
pub fn on_pointer_down(&mut self, x: f32, y: f32)
Called when a pointer/mouse/touch press begins.
Sourcepub fn on_pointer_move(&mut self, x: f32, y: f32, dt: f32)
pub fn on_pointer_move(&mut self, x: f32, y: f32, dt: f32)
Called each frame while the pointer is held down.
dt is the time since the last move event (for velocity calculation).
Sourcepub fn on_pointer_up(&mut self) -> InertiaN<[f32; 2]>
pub fn on_pointer_up(&mut self) -> InertiaN<[f32; 2]>
Called when the pointer is released. Returns an InertiaN carrying
the momentum from the drag.
Sourcepub fn is_dragging(&self) -> bool
pub fn is_dragging(&self) -> bool
Whether the pointer is currently held down.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DragState
impl RefUnwindSafe for DragState
impl Send for DragState
impl Sync for DragState
impl Unpin for DragState
impl UnsafeUnpin for DragState
impl UnwindSafe for DragState
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