dragIntent()
Start dragging after clear movement.
Try the example
Move the task handle slightly, then drag deliberately. Dragging starts after 8 px. Focus the same handle and use arrow keys to move it without dragging.
Move more than 8 px to start dragging.
Add it to your project
- Copy the HTML. Place the markup inside the component where this behavior belongs. The preview’s visual classes are website styles; use your own design system.
- Connect the behavior. Copy the JavaScript tab and call its exported
mount(element)after your component’s elements exist. Replace simulated delays and data operations with your own application code. - Clean up. Call the returned cleanup when the component unmounts. It aborts the example’s listeners and releases the helper’s timers, observers or state.
API and lifecycle
Attach the helper to a dedicated handle. A primary pointer press starts a session; onStart runs only after movement passes the threshold, which defaults to 5 px. onMove receives viewport-relative dx and dy values.
- Interface
threshold, onStart/onMove/onEnd; returns cleanup- Lifecycle
- The returned cleanup removes pointer listeners and releases capture. onEnd receives cancelled=true if capture is lost, the pointer is cancelled, or cleanup ends an active drag.
Accessibility and safety
Implementation notes
Provide keyboard alternatives; touch-action:none blocks scroll on the handle.
Dragging needs a keyboard alternative such as move buttons or arrow-key controls. Choose touch-action on the handle deliberately: none prevents touch scrolling there.
What to check
Check small movements do not drag. Test pointer cancellation, releasing outside the handle, touch scrolling and equivalent movement using a keyboard.