This API enables the user to get updates describing the pitch angle of the mobile device.

The RelativePitch always starts at a value of 0 and, as the device is tilted upward or downward, the relative pitch angle is reported in degrees. Tilting the device downward causes the relative pitch value to decrease, whereas upward tilting causes the value to increase.


var relativePitch = new MotionStack.RelativePitch({continuous: false});

relativePitch.start(function (e) {

  if (Math.abs(e.angle) > 360) {


new MotionStack.RelativePitch([options])

Create a new RelativePitch instance object.

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

  • continuous {Boolean}
  • Determines whether the pitch angle can grow indefinitely. When this is false, the value of relative pitch angle is bounded between -180 and +180 degrees.

    Default: false

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

    Default: false

var pitch = new MotionStack.RelativePitch({continuous: true});

Instance Methods

start(callback, [context])

Start receiving relative pitch updates.

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

  • function(e)
  • e.angle {Number}
    Current pitch angle of the device as measured from the initial pitch when the start() method was first invoked on the given instance
  • e.timeStamp {Number}
    The time in milliseconds when the data is collected
context Object Context in which to invoke the callback (optional).
relativePitch.start(function(e) {


Stop relative pitch updates.