This API enables the user to register when the mobile device is shaken.

ShakeProgress aggregates Shake events based on a minimum number of shakes and minimum amount of time since shaking began. It returns a progress value that starts at 0 and increases as the device is shaken until progress reaches a value of 1. At this time, the shake gesture is considered complete. The API only fires when the progress is updated. ShakeProgress relies on the device's Accelerometer sensor.


var shakeProgress = new MotionStack.ShakeProgress({
  minShakes: 10,
  minTime: 1000,
  direction: "all"

shakeProgress.start(function (e) {

  if (e.progress == 1) {


new MotionStack.ShakeProgress([options])

Create a new ShakeProgress instance object.

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

  • minShakes {Number}
  • Minimum number of shakes to reach a progress of 1.

    Default: 10

  • minTime {Number}
  • Minimum time in milliseconds since shaking began to reach a progress of 1.

    Default: 1000

  • minStrength {Number}
  • Specifies the minimum strength of a shake required to fill progress.

    Default: 0

  • direction {String}
  • Specifies the direction of a shake required to fill progress. Options are all, forward, or side.

    Default: all

    • all - All shakes are detected.
    • forward - Only forward shakes are detected.
    • side - Only side shakes are detected.
  • fireOnAnimationFrame {Boolean}
  • Only emit the latest event within requestAnimationFrame intervals.

    Default: false

var shakeProgress = new MotionStack.ShakeProgress({
  minShakes: 10,
  minTime: 1000

Instance Methods

start(callback, [context])

Start receiving shake progress updates.

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

  • function(e)
  • e.progress {Number}
    Value between 0 and 1 indicating how complete the ShakeProgress events are. A value of 0 means the device has not been shaken. A value of 1 means progress has completed and then progress resets back to 0 to begin the cycle again.
  • e.completions {Number}
    Summation of progress since first shake detected. This is useful to count the number of times progress has reached 1, i.e. number of times completed.
  • e.strength {Number}
    The strength of the detected shake in meters per seconds squared.
  • e.timeStamp {Number}
    The time in milliseconds when progress was updated.
context Object Context in which to invoke the callback (optional).
shakeProgress.start(function(e) {


Stop shakeProgress updates.