Long press hook
  • Introduction
  • Installation
  • Basics
  • Advanced
    • Definition
    • Callback
    • Options
      • Configuration
        • Events detection
        • Long press threshold
      • React events
        • Persisting event
        • Filtering events
      • Callbacks
        • Press started
        • On move
        • Press finished
        • Long press cancelled
      • Cancellation
        • Cancel outside element
        • Cancel on movement
    • Hook result / Bind function
      • Context
      • Handlers
  • Examples
    • Advanced usage example
    • Live examples
      • Version 3
      • Version 2 (deprecated)
      • Version 1 (deprecated)
  • Migration
    • V1 to V2
    • V2 to V3
    • ⚠️V3.1+
    • Change log
  • Contributions
    • ❤️Donations
    • Pull requests policy
  • Architectural Decisions
    • V1 and V2 deprecation
    • Moving to new repository
Powered by GitBook
On this page

Was this helpful?

  1. Advanced
  2. Options
  3. Callbacks

On move

When moving over element

PreviousPress startedNextPress finished

Last updated 1 year ago

Was this helpful?

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 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 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,
 }
binder
cancelOnMovement