Skip to content

Instantly share code, notes, and snippets.

View mees305's full-sized avatar

Aramis Camacho mees305

View GitHub Profile
@mees305
mees305 / shake.js
Last active August 29, 2015 14:16 — forked from ucavus/shake.js
/*
The only required option is the "success" callback. Usage:
var shake = new Shake({
frequency: 300, //milliseconds between polls for accelerometer data.
waitBetweenShakes: 1000, //milliseconds to wait before watching for more shake events.
threshold: 12, //how hard the shake has to be to register.
success: function(magnitude, accelerationDelta, timestamp) {}, //callback when shake is detected. "this" will be the "shake" object.
failure: function() {}, //callback when watching/getting acceleration fails. "this" will be the "shake" object.
});

Keybase proof

I hereby claim:

  • I am mees305 on github.
  • I am 5partan1337 (https://keybase.io/5partan1337) on keybase.
  • I have a public key whose fingerprint is ADBB B224 1422 6323 9398 F68C D2B5 C7F3 A97D B63D

To claim this, I am signing this object:

var shake = (function () {
var shake = {},
watchId = null,
options = { frequency: 300 },
previousAcceleration = { x: null, y: null, z: null },
shakeCallBack = null;
// Start watching the accelerometer for a shake gesture
shake.startWatch = function (onShake) {
if (onShake) {