Interface Accelerometer

This plugin provides access to the device's accelerometer. The accelerometer is a motion sensor that detects the change (delta) in movement relative to the current device orientation, in three dimensions along the x, y, and z axis.

Index

Methods

Methods

public clearWatch(watchID: WatchHandle)

Stop watching the Acceleration referenced by the watchID parameter.

Parameters

  • watchID: WatchHandle

    The ID returned by navigator.accelerometer.watchAcceleration.

public getCurrentAcceleration(accelerometerSuccess: (acceleration: Acceleration) => void, accelerometerError: () => void)

Get the current acceleration along the x, y, and z axes. These acceleration values are returned to the accelerometerSuccess callback function.

Parameters

  • accelerometerSuccess: (acceleration: Acceleration) => void

    Success callback that gets the Acceleration object.

  • accelerometerError: () => void

    Success callback

public watchAcceleration(accelerometerSuccess: (acceleration: Acceleration) => void, accelerometerError: () => void, accelerometerOptions?: AccelerometerOptions): WatchHandle

Retrieves the device's current Acceleration at a regular interval, executing the accelerometerSuccess callback function each time. Specify the interval in milliseconds via the acceleratorOptions object's frequency parameter. The returned watch ID references the accelerometer's watch interval, and can be used with navigator.accelerometer.clearWatch to stop watching the accelerometer.

Parameters

  • accelerometerSuccess: (acceleration: Acceleration) => void

    Callback, that called at every time interval and passes an Acceleration object.

  • accelerometerError: () => void

    Error callback.

  • accelerometerOptions?: AccelerometerOptions optional

    Object with options for watchAcceleration

Returns

WatchHandle