shake-direction

0.0.2 • Public • Published

shake-direction Build Status

A custom 'shake' event with direction JavaScript plugin for mobile web browsers using device accelerometer.

Install

$ npm install --save shake-direction

Usage

'use strict';


import ShakeDirection from './';

var se = new ShakeDirection({
	threshold: 20,
	timeout: 1000
});
se.start();

window.addEventListener('shake-x-positive', () => {
	console.log('X Positive!');
}, false);
window.addEventListener('shake-x-negative', () => {
	console.log('X Negative!');
}, false);
window.addEventListener('shake-y-positive', () => {
	console.log('Y Positive!');
}, false);
window.addEventListener('shake-y-negative', () => {
	console.log('Y Negative!');
}, false);
window.addEventListener('shake-z-positive', () => {
	console.log('Z Positive!');
}, false);
window.addEventListener('shake-z-negative', () => {
	console.log('Z Negative!');
}, false);

API

ShakeDirection(threshold, timeout)

threshold

Type: int
Default: 15

optional shake strength threshold.

options

timeout

Type: int
Default: 1000

determines the frequency of event generation.

License

MIT © elzup

Dependents (0)

Package Sidebar

Install

npm i shake-direction

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • elzup