You are reading 13.1.0. See this page in 13.4.1.
Titanium.Gesture
Extends Titanium.ModuleTitanium.Proxy
The Gesture module is responsible for high-level device gestures such as orientation changes and shake gestures.
Properties 6
Inherited from Titanium.Proxy
The name of the API that this proxy corresponds to.
Inherited from Titanium.Proxy
Indicates if the proxy will bubble an event to its parent.
Default: true
Indicates if the device is currently held in landscape form.
Value is true if in landscape, and false otherwise.
Inherited from Titanium.Proxy
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
Orientation of the device.
Value may be one of the group of Titanium.UI orientation constants, Titanium.UI.PORTRAIT, Titanium.UI.UPSIDE_PORTRAIT, Titanium.UI.LANDSCAPE_LEFT, Titanium.UI.LANDSCAPE_RIGHT, Titanium.UI.FACE_UP, Titanium.UI.FACE_DOWN, or Titanium.UI.UNKNOWN.
On iOS and Windows, returns the current orientation of the device, regardless of the window orientation. To determine the current window orientation, use Window.orientation.
To set the allowable orientations for a window, see Titanium.UI.Window.orientationModes.
Indicates if the device is currently held in portrait form.
Value is true if in portrait, and false otherwise.
Methods 5
Inherited from Titanium.Proxy
Adds the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to invoke when the event is fired. 4 fields
|
applyProperties
since 3.0.0Inherited from Titanium.Proxy
Applies the properties to the proxy.
| Parameters | Type | Description |
|---|---|---|
| props | Dictionary | A dictionary of properties to apply. |
Inherited from Titanium.Proxy
Fires a synthesized event to any registered listeners.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| event? | Dictionary | A dictionary of keys and values to add to the Titanium.Event object sent to the listeners. |
Inherited from Titanium.Proxy
Removes the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to remove. Must be the same function passed to 4 fields
|
Stops the gesture listener.
In case you use Titanium.Gesture.landscape or Titanium.Gesture.portrait it will attach the orientation
listener automatically. If you just use it once you can use this method to stop the listener.
Events 2
Fired when the device orientation changes.
On Android, note that the application must have a heavyweight window or tab group open
in order to receive the orientationchange event. It is not necessary for the heavyweight
window to be the topmost window.
Almost all real-world applications will have a heavyweight window or a tab group. This is
only likely to be an issue if you create a test case or test application that adds an
orientation change listener from app.js without opening a heavyweight window.
| Event properties | Type | Description |
|---|---|---|
| orientation | Number | Orientation of the device. |
Fired when the device is shaken.
A shake gesture consists of a series of quick accelerations, and is represented by a series of shake events.
The timestamp property represents the interval between shake events. It is measured in
milliseconds on Android, and in seconds on iOS.
| Event properties | Type | Description |
|---|---|---|
| timestamp | Number | Time interval since previous shake event. On iOS, this value is 0 for the first shake event in a series. |
| x | Number | Acceleration along the X axis, in Gs. |
| y | Number | Acceleration along the Y axis, in Gs. |
| z | Number | Acceleration along the Z axis, in Gs. |