Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LongPressHandler

Class that can be used to track long presses on an HTML Element. A long press is a press that lasts a minimum duration (see the timeout member) while the pointer is not moved more than a certain threshold (see the moveThreshold member).

Hierarchy

  • LongPressHandler

Index

Constructors

constructor

  • new LongPressHandler(element: HTMLElement, onLongPress: (event: MouseEvent | Touch) => void, onTap?: undefined | ((event: MouseEvent | Touch) => void)): LongPressHandler
  • Default constructor.

    Parameters

    • element: HTMLElement

      The HTML element to track.

    • onLongPress: (event: MouseEvent | Touch) => void

      The callback to call when a long press occurred.

        • (event: MouseEvent | Touch): void
        • Parameters

          • event: MouseEvent | Touch

          Returns void

    • Optional onTap: undefined | ((event: MouseEvent | Touch) => void)

      Optional callback to call on a tap, i.e. when the press ends before the specified timeout.

    Returns LongPressHandler

Properties

buttonId

buttonId: number = 0

Mouse button id that should be handled by this event.

Readonly element

element: HTMLElement

The HTML element to track.

moveThreshold

moveThreshold: number = 5

If the cursor moves more than the given number of pixels, it is not a long-press, but a pan.

onLongPress

onLongPress: (event: MouseEvent | Touch) => void

The callback to call when a long press occurred.

Type declaration

    • (event: MouseEvent | Touch): void
    • Parameters

      • event: MouseEvent | Touch

      Returns void

Optional onTap

onTap: undefined | ((event: MouseEvent | Touch) => void)

Optional callback to call on a tap, i.e. when the press ends before the specified timeout.

timeout

timeout: number = 500

How long to wait (in ms) until a press is considered a long press.

Methods

dispose

  • dispose(): void

Generated using TypeDoc