nvue-event.md 2.4 KB
Newer Older
Q
qiang 已提交
1

Q
qiang 已提交
2
Weex provide the ability to let events trigger action, like starting a JavaScript when a user click on a component. Below are the common event attributes that can be added to weex components to define event actions.
Q
qiang 已提交
3

Q
qiang 已提交
4
### Event penetration
Q
qiang 已提交
5

Q
qiang 已提交
6
> The principle of native event delivery under Android and iOS is different, only for iOS here.
Q
qiang 已提交
7

Q
qiang 已提交
8
When a parent view has multiple peer views, iOS will select the highest level View to respond to the event, and the underlying view event will never be responded.
Q
qiang 已提交
9

Q
qiang 已提交
10
Weex add attribute `eventPenetrationEnabled` to `<div>` component. When the value is `true`(default would be `false`), the view's children views still respond to the event normally, while the view itself will not respond to the event, but pass the event to the lower level View.
Q
qiang 已提交
11 12


Q
qiang 已提交
13
### View interactivity
Q
qiang 已提交
14

Q
qiang 已提交
15
Weex add attribute `userInteractionEnabled` to `<div>` component. When the value is `false`(default would be `true`), neither the view nor its children views respond to the event. The event is passed to the lower layer View.
Q
qiang 已提交
16 17 18

**longpress**

Q
qiang 已提交
19
If a `longpress` event is bound to a component, the event will be triggered when user long press on it.
Q
qiang 已提交
20

Q
qiang 已提交
21
**event object**
Q
qiang 已提交
22 23 24 25 26


|key			|value		|备注																|
|--				|--				|--																	|
|type			|longpress|																		|
Q
qiang 已提交
27 28
|target		|					|The target component where the event is triggered							|
|timestamp|					|Timestamp when event is triggered	|
Q
qiang 已提交
29 30 31 32


**Appear**

Q
qiang 已提交
33
If a appear event is bound to a component inside a scrollable container, the event will be triggered when the component comes to be visible.
Q
qiang 已提交
34

Q
qiang 已提交
35
**event object**
Q
qiang 已提交
36

Q
qiang 已提交
37
|key		|value					|notes							|
Q
qiang 已提交
38 39
|--			|--						|--								|
|type		|appear					|								|
Q
qiang 已提交
40 41 42
|target		|						|The target component where the event is triggered		|
|timestamp	|						|Timestamp when event is triggered|
|direction	| ```up```or ```down```	|The direction in which the scroller is scrolling.		|
Q
qiang 已提交
43 44 45 46


**Disappear**

Q
qiang 已提交
47
If a `disappear` event is bound to a component inside a scrollable container, the event will be triggered when the component scrolls out of viewport and disappears from your sight.
Q
qiang 已提交
48

Q
qiang 已提交
49
**event object**
Q
qiang 已提交
50 51 52 53

|key			|value									|备注														|
|--				|--											|--															|
|type			|disappear							|																|
Q
qiang 已提交
54 55 56
|target		|												|The target component where the event is triggered	|
|timestamp|												|Timestamp when event is triggered|
|direction| ```up```or ```down```	|The direction in which the scroller is scrolling. Could be `up` or `down`				|
Q
qiang 已提交
57 58 59 60