Skip to content

sud.onDeviceMotionChange ​

JS
    sud.onDeviceMotionChange(function callback)

Listens for device motion change events. Each call to this api sets an independent listener callback and does not overwrite previous ones.

The interval follows the interval parameter of startDeviceMotionListening(). Listening starts automatically after the interface is called.

Parameters

  • function callback: Callback function for device motion change events

Parameters of the callback function

  • Object res: Returns device motion data

Properties of the device motion data:

PropertyTypeDescription
alphanumberWhen the phone coordinates X/Y coincide with the earth X/Y, alpha is the rotation angle around the Z axis, ranging in [0, 2*PI). Rotating counterclockwise decreases the alpha value.
betanumberWhen the phone coordinates Y/Z coincide with the earth Y/Z, beta is the rotation angle around the X axis, ranging in [-1*PI, PI).
gammanumberWhen the phone X/Z coincide with the earth X/Z, gamma is the rotation angle around the Y axis, ranging in [-1*PI/2, PI/2).