Event Classes

Event.AccelerationEvent

An instance of this class is passed to acceleration event handlers.

Contains the usual properties, plus those documented below.

Event.Acceleration Properties

Event.AccelerationEvent#accelX

Event.AccelerationEvent#accelX -> float

Acceleration along the X axis in g's

Event.AccelerationEvent#accelY

Event.AccelerationEvent#accelY -> float

Acceleration along the Y axis in g's

Event.AccelerationEvent#accelZ

Event.AccelerationEvent#accelZ -> float

Acceleration along the Z axis in g's

Event.DragEvent

An instance of this class is passed to drag event listeners.

Event.Drag Properties

Event.DragEvent#down

Event.DragEvent#down -> Event

The DOM event that started the initial drag. The target property of this object is the element that the user is attempting to drag.

Event.DragEvent#move

Event.DragEvent#move -> Event

The DOM event that fires while dragging. Using this event, you can determine where the user has moved his/her finger to on the screen since the beginning of the drag.

Not provided on Event.dragEnd events.

Event.DragEvent#up

Event.DragEvent#up -> Event

The DOM event that fires after the user lifts their finger, thereby ending the drag. You can determine the final position on the screen and the element that was dropped on inspecting this event.

Only provided on Event.dragEnd events.

Event.FlickEvent

An instance of this class is passed to flick event handlers.

Flick event fires on the element at which the flick originated. In addition to the usual properties, this event has the attributes documented below.

Event.FlickEvent Properties

Event.FlickEvent#origin

Event.FlickEvent#origin -> object

The x/y location of the beginning of the flick.

{
  x: <the x coordinate of the flick origin>,
  y: <the y coordinate of the flick origin>
}

Event.FlickEvent#velocity

Event.FlickEvent#velocity -> object

The velocity of the flick event.

{
  x: <the velocity of the flick in the x direction>,
  y: <the velocity of the flick in the y direction>
}

Event.GestureEvent

An instance of this class is passed to gesture event handlers.

The available gesture events are:

  • gesturestart: fires when the user puts 2 fingers on the screen, usually to pinch or rotate
  • gesturechange: fires when 1 or both fingers moves on the screen
  • gestureend: fires when the user lifts 1 or both fingers

This event is provided by the browser, but documented here until it becomes part of a formal standard.

In addition to the usual properties, this event has the attributes documented below.

Event.GestureEvent Properties

Event.GestureEvent#rotation

Event.GestureEvent#rotation -> float

The change in the rotation since the start of the event. Clockwise is positive and counter-clockwise is negative.

Event.GestureEvent#scale

Event.GestureEvent#scale -> float

A scale factor of the gesture.

The initial value is 1.0. If the event's scale is < 1.0, then the users fingers are getting closer. If the event's scale is > 1.0, then the users fingers are getting further away.

Event.OrientationChangeEvent

An instance of this class is passed to orientationchange event handlers.

This event is provided by the browser, but is documented here until it becomes part of a formal standard.

In addition to the usual properties, this event has the attributes documented below.

Event.OrientationChangeEvent Properties

Event.OrientationChangeEvent#pitch

Event.OrientationChangeEvent#pitch -> float

The pitch of the device.

Event.OrientationChangeEvent#position

Event.OrientationChangeEvent#position -> Number

The position of the device.

Possible values include:

  • 0 (Face up)
  • 1 (Face down)
  • 2 (Up, default portrait)
  • 3 (Down, upside down)
  • 4 (Left, left side down)
  • 5 (Right, right side down)

Event.OrientationChangeEvent#roll

Event.OrientationChangeEvent#roll -> float

The roll of the device.

Event.RelaunchEvent

An instance of this class is passed to Event.relaunch listeners.

Event.RelaunchEvent Properties

Event.RelaunchEvent#params

Event.RelaunchEvent#params -> Object

An object that contains the launch parameters passed to the application from the application manager. In the case that a user opened the application, this object will be empty.

Event.ScreenRotateEvent

An instance of this class is passed to screen rotation event handlers.

In addition to the usual properties, this event has the attributes documented below.

Event.ScreenRotateEvent Properties

Event.ScreenRotateEvent#orientation

Event.ScreenRotateEvent#orientation -> String

The new orientation of the screen.

Possible values are:

  • up
  • down
  • left
  • right

Up is the default. Down is upside down, left is rotated counter-clockwise, right is rotated clockwise.

Event.ShakeEvent

An instance of this class is passed to shake event handlers.

In addition to the usual properties, this event has the attributes documented below.

Event.ShakeEvent Properties

Event.ShakeEvent#magnitude

Event.ShakeEvent#magnitude -> Number

The magnitude of the shake in g's. Larger numbers indicate more vigorous shaking.