Getting Started

A quick start guide to get up and running quickly with MotionStack

Download the latest MotionStack release

You can download a copy of the latest version of the MotionStack (v1.2.0) here.

Including MotionStack in your project

Require with npm

Installing MotionStack via npm can be done with the following command:

$ npm install --save motionstack

We recommend using MotionStack with a CommonJS module system like browserify or webpack.

Then require the motionstack package.

var MotionStack = require('motionstack');

Source without npm

Source the minified distribution using the script tag in your HTML page.

<script type="text/javascript" src="motionstack.min.js"></script>

Interacting with MotionStack

Once the library has loaded you can then interact with MotionStack APIs in your web application.

Instantiate Object

All MotionStack APIs follow the same conventions in their lifecycle and usage. First create a new instance of the API you want. For example, create a new instance of the ShakeProgress API

var shakeProgress = new MotionStack.ShakeProgress();

Start Listening

Then provide a callback function and start listening to the sensor events. A simple example logs the progress as a user shakes their mobile device.

shakeProgress.start(function(data) {
  // Log data as it arrives (from 0 to 1)
  console.log(data.progress);
});

Stop Listening

Stop listening for events when the listener is not needed any longer.

shakeProgress.stop();