On move

When moving over element

Name

onMove

Type

Javascript
(event, meta) => void
TypeScript
(
  event: 
  | ReactMouseEvent<Target>
  | ReactTouchEvent<Target>
  | ReactPointerEvent<Target>,
  meta: { context?: Context; reason?: LongPressCallbackReason }
) => void

Default value

undefined

Description

Called when moving over element. Because long press binder will overwrite any movement handler, this callback is called when ANY movement occur (not necessarily after press). This way you can still call your regular movement handler using this callback.

All processing will happen only if element is pressed and cancelOnMovement option is enabled.

Since current position is extracted from event after this callback is called, you can potentially manipulate event position to model more complex behaviours. Position is extracted as follows:

 // Touch event
 return {
  x: event.touches[0].pageX,
  y: event.touches[0].pageY,
 }
 
 // Mouse and pointer events
 return {
  x: event.pageX,
  y: event.pageY,
 }

Last updated