Provides the status of available device sensors.

The SensorControlSwitch API is used to determine if certain device motion events exist and report the appropriate data. In particular it checks for the devicemotion, deviceorientation, and deviceorientationabsolute events, and waits for up to 3000 milliseconds for these events to return data.


var sensorControlSwitch = new MotionStack.SensorControlSwitch();

sensorControlSwitch.start(function(e) {


new MotionStack.SensorControlSwitch([options])

Create a new SensorControlSwitch instance object.

Argument Type Description
options Object Options to pass in for the new SensorControlSwitch instance (optional)

  • fireOnAnimationFrame {Boolean}
  • Only emit the latest event within requestAnimationFrame intervals.

    Default: false

var sensorControlSwitch = new MotionStack.SensorControlSwitch();

Instance Methods

start(callback, [context])

Start receiving sensorControlSwitch updates.

Argument Type Description
callback Function Callback function that receives an object as an argument

  • function(e)
  • e.accelerationExists {Boolean}
    Specifies if the devicemotion.acceleration event exists and returns valid data.
  • e.accelerationIncludingGravityExists {Boolean}
    Specifies if the devicemotion.accelerationIncludingGravity event exists and returns valid data.
  • e.rotationRateExists {Boolean}
    Specifies if the devicemotion.rotationRate event exists and returns valid data.
  • e.orientationExists {Boolean}
    Specifies if the deviceorienation event exists and returns valid data.
  • e.orientationAbsoluteExists {Boolean}
    Specifies if the deviceorienationabsolute event exists and returns valid data.
  • e.motionExists {Boolean}
    Specifies if any device motion event devicemotion',deviceorienation, ordeviceorienationabsoluteexists and returns valid data. </li> </ul> </td> </tr> <tr> <td>context`
Object Context in which to invoke the callback (optional).
sensorControlSwitch.start(function(e) {


Stop sensorControlSwitch updates.