Experiment Feature
Weex encapsulates native touch events to provide a gesture system. Using gesture is similar to use event in Weex.
For now, there are four types of gestures:
touchstart
will be fired when a touch point is placed on the touch surface.touchmove
will be fired when a touch point is moved along the touch surface.touchend
will be fired when a touch point is removed from the touch surface.stopPropagation
every touch event will be fired, you can control touch event whether should be bubbled by return true(should bubble) or false(touch event consumed by this view, will not be bubbled). this can be used to handle touch confliction between views. (since v0.18+)panstart
will be fired when pan startpanmove
will be fired when pan movepanend
will be fired when pan endstate
property. Note: These gestures are in conflict with click event on Android currently.horizontalpan
verticalpan
The Touch gesture and Pan is very close to each other, with following features hold:
Users may choose their gesture according to their situation.
The following properties can be used in gesture callback:
direction
. Only exists for Swipe gesture. Indicate the direcion of the swipe, choose from up
, left
, bottom
, right
.changedTouches
. An array of motion for every touch pointer that has contribute to the current gesture.changedTouches
is an array, with the following properties in its children:
identifier
. A unique identifier for a touch pointer.pageX
. The X coordinate of the touch pointer relative to the left edge of the document.pageY
. The Y coordinate of the touch pointer relative to the top of the document.screenX
. The X coordinate of the touch point relative to the left edge of the screen.screenY
. The Y coordinate of the touch point relative to the top edge of the screen.force
. A float value that represents the amount of pressure the user is applying to the touch surface. This is a value between 0.0 (no pressure) and 1.0 (the maximum amount of pressure the hardware can recognize).iOS only and force is included in iPhone 6S and later models
Currently, Weex Android do not support listening to gesture on scroller
, list
and webview
, as it would lead a large amount of event conflicting.