TouchEvent

Represents a touch event object, inherited from Event, used to describe the state changes of a finger on a touch surface (such as a touch screen), such as finger movement, click, long press, etc.

This event object contains one or more touch points, through which developers can understand the state changes of fingers on the touch surface.

Instance property

detail

detail: {
  x: number,
  y: number,
}

Represents the touch point position of the first finger.

  • x: The horizontal axis position of the touch point in the current LynxView coordinate system.
  • y: The vertical axis position of the touch point in the current LynxView coordinate system.

touches

touches: Touch []

Represents the Touch object currently on the touch plane. Each Touch object describes the touch point information of the corresponding finger. The format is as follows:

{
  identifier: number,   // Unique identifier of the touch point, which remains unchanged during the same touch process
  x: number,            // The horizontal position of the touch point in the coordinate system of the element actually touched
  y: number,            // The vertical position of the touch point in the coordinate system of the element actually touched
  pageX: number,        // The horizontal position of the touch point in the current LynxView coordinate system
  pageY: number,        // The vertical position of the touch point in the current LynxView coordinate system
  clientX: number,      // The horizontal position of the touch point in the current window coordinate system
  clientY: number,      // The horizontal position of the touch point in the current window coordinate system
}

changedTouches

changedTouches: Touch []

Indicates a Touch object whose state has changed compared to the last touch event, such as from nothing to something, position change, from something to nothing. The format of changesTouches is the same as that of touches.

TouchEvent type

touchstart

Indicates that the finger begins to touch the touch surface. target is the element that contains the touch point and is closest to the user.

touchmove

Indicates that the finger moves on the touch surface. target is always the same as target of touchstart.

touchend

Indicates that the finger leaves the touch surface. target is the same as target of touchstart. The touch point that has left the screen can be found in changedTouches.

touchcancel

Indicates that the touch event is interrupted by the system or Lynx external gesture, such as system pop-up window or incoming call. target is the same as target of touchstart. The interrupted touch point can be found in changedTouches.

tap

Indicates that the finger clicks on the touch surface. target is the element that contains the touch point and is closest to the user. Only the first finger can trigger it. When the finger moves beyond a certain threshold or triggers the UI at the touch position to slide, the tap event cannot be triggered.

In addition, this event and the longpress event are mutually exclusive in event monitoring. That is, if the front end monitors two events at the same time, the two events will not be triggered at the same time, and longpress takes priority.

longpress

Indicates that the finger long presses on the touch surface. target is the element that contains the touch point and is closest to the user. The interval for long press triggering is 500 ms.

Compatibility

LCD tables only load in the browser

Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.