Skip to content

chadwilson/CordovaMotionWatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shake Gesture Detection for Cordova npm version

THIS IS OUT OF DATE -- This is intended for internal use atm. If you find this and wish to use it feel free, but it is significantly altered from it's original form, and serves a particular function and as such is unlikely to be maintained for anything other than that function. If you would like to make alterations, please feel free to reach out.

Apache Cordova / PhoneGap Plugin to detect when a physical device performs a shake gesture.

This is based on a standalone JavaScript implementation I wrote last year (gist).

Install

Requires Cordova v5.0.0 or above.

Latest published version on npm

cordova plugin add cordova-plugin-shake

Latest version from GitHub

cordova plugin add https://github.com/leecrossley/cordova-plugin-shake.git

Usage

You do not need to reference any JavaScript, the Cordova plugin architecture will add a shake object to your root automatically when you build.

NB: There is no native component to this plugin but it depends on the device motion plugin (added when this plugin is added).

Example

var onShake = function () {
  // Fired when a shake is detected
};

var onError = function () {
  // Fired when there is an accelerometer error (optional)
};

// Start watching for shake gestures and call "onShake"
// with a shake sensitivity of 40 (optional, default 30)
shake.startWatch(onShake, 40 /*, onError */);

// Stop watching for shake gestures
shake.stopWatch();

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published