Improve drag and drop interactions by adjusting activation constraints
Adjusts drag activation constraints for pointer and touch sensors, enabling instant drag initiation in edit mode with a lower activation distance and no delay, while maintaining a higher threshold and delay outside of edit mode.
This commit is contained in:
@@ -254,13 +254,23 @@ export default function ServicesPage() {
|
||||
return rows;
|
||||
}, [services, orderedIds]);
|
||||
|
||||
// Touch sensor uses delay so a tap-to-open isn't misread as a drag;
|
||||
// pointer sensor needs only the tiny activation distance so mouse
|
||||
// drags feel responsive on the desktop preview.
|
||||
// Drag activation is tuned per-mode:
|
||||
// * Outside edit mode we never want a drag (cards are only tappable
|
||||
// to place an order), so a slightly higher distance threshold
|
||||
// keeps the long-press-to-enter-edit gesture clean.
|
||||
// * Inside edit mode the user has already opted into reordering, so
|
||||
// drags should start instantly with no touch delay — matching the
|
||||
// iOS home-screen "jiggle" feel. A tiny `distance: 2` activation
|
||||
// still tolerates the natural finger jitter that happens before
|
||||
// intentional movement, without making drags feel sluggish.
|
||||
const sensors = useSensors(
|
||||
useSensor(PointerSensor, { activationConstraint: { distance: 6 } }),
|
||||
useSensor(PointerSensor, {
|
||||
activationConstraint: { distance: editMode ? 2 : 6 },
|
||||
}),
|
||||
useSensor(TouchSensor, {
|
||||
activationConstraint: { delay: 150, tolerance: 8 },
|
||||
activationConstraint: editMode
|
||||
? { distance: 2 }
|
||||
: { delay: 150, tolerance: 8 },
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user