Skip to main content
Version: v3

onGesture

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

Listen to user gesture events, only one event is allowed to be registered, if multiple registrations will cause the last registered event to fail.

Type

function onGesture(option: Option): void

Simplified calling method

function onGesture(callback: (event: GestureEvent) => PreventDefault): void

Parameters

Option

PropertyTypeRequiredDefaultValueDescriptionAPI_LEVEL
callback(event: GestureEvent) => PreventDefaultY-Gesture event callback function2.0

GestureEvent

TypeDescription
numberGesture event name, value reference gesture event constants

PreventDefault

TypeDescription
booleanWhether to skip the default gesture behavior, true - skip, false - don't skip

Constants

Gesture event constants

ConstantDescriptionAPI_LEVEL
GESTURE_UPGesture up slide2.0
GESTURE_DOWNGesture down slide2.0
GESTURE_LEFTGesture left slide2.0
GESTURE_RIGHTGesture right slide2.0

Example

import { onGesture, GESTURE_UP } from '@zos/interaction'

onGesture({
callback: (event) => {
if (event === GESTURE_UP) {
console.log('up')
}
return true
},
})