pub struct Reorder { /* private fields */ }Expand description
Drag-to-reorder for a list() (docs/list.md): the handler that applies a committed move,
an optional guard consulted while the drag is live, and whether the gesture is offered
right now. A list is reorderable exactly when it carries one of these
(list(..).reorderable(Reorder::new(f))).
The platform’s own mechanism does the dragging (the macOS drop gap, the iOS long-press
lift, Android’s ItemTouchHelper) where the backend supports it (probe Cap::ListReorder;
docs/list.md has the matrix).
Implementations§
Source§impl Reorder
impl Reorder
Sourcepub fn new(moved: impl Fn(usize, usize) + 'static) -> Reorder
pub fn new(moved: impl Fn(usize, usize) + 'static) -> Reorder
moved(from, to) runs after a committed move: row from now sits at row to. Apply the
same rotation to the backing data (let it = v.remove(from); v.insert(to, it);), and
persist it if the order should survive a relaunch. Runs on the main thread at the next
event drain, never inside the native drop callback.
Sourcepub fn guard(
self,
g: impl Fn(usize, usize) -> ReorderVerdict + 'static,
) -> Reorder
pub fn guard( self, g: impl Fn(usize, usize) -> ReorderVerdict + 'static, ) -> Reorder
Veto or override drops while the drag is live: called synchronously from the native
validate hook with (from, proposed_to). Return ReorderVerdict::Deny to refuse,
ReorderVerdict::Retarget to accept at a different index (a “pinned rows” pattern), or
ReorderVerdict::Allow to accept as proposed (the default without a guard). Keep it
pure (read state, decide, return); it runs inside the platform’s drag callback.
Sourcepub fn enabled<M>(self, on: impl IntoReactive<bool, M>) -> Reorder
pub fn enabled<M>(self, on: impl IntoReactive<bool, M>) -> Reorder
Whether the gesture is offered right now (default true): a constant or a reactive
bool, read when the platform asks whether a drag may begin, so an edit mode or a
loading state can withhold it without rebuilding the list.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Reorder
impl !Send for Reorder
impl !Sync for Reorder
impl !UnwindSafe for Reorder
impl Freeze for Reorder
impl Unpin for Reorder
impl UnsafeUnpin for Reorder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more