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

This indicates a single tap on the touch surface. The target is the element containing the touch point and closest to the user. Only the first finger can trigger this event. If the finger moves beyond a certain threshold, or if an element in the event response chain slides, the tap event will not trigger.

Furthermore, this event and the longpress event are mutually exclusive in event listening. That is, if the front-end listens for both events simultaneously, they will not trigger concurrently; longpress takes precedence.

longpress

This indicates a long press on the touch surface. The target is the element containing the touch point and closest to the user. Only the first finger can trigger this event. The longpress event will not trigger if the finger moves beyond a certain threshold or the long press interval is less than 500 ms.

click

This indicates a single click on the touch plane. target is the element containing the touch point, closest to the user, and listening for the click event. Only the first finger can trigger this event. Unlike the tap event, the click event will not trigger if the finger moves away from the element closest to the user and listening for the click event, or if an element in the event response chain of that element slides.

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.