# shake2.js

> A custom 'shake' event plugin for mobile web browsers using device accelerometer.

Latest version **1.0.1** (published 2018-10-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install shake2.js
pnpm add shake2.js
yarn add shake2.js
bun add shake2.js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-10-17 |
| First published | 2018-10-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Samuel Ramos Barroso, Alex Gibson |
| Maintainers | losnen |

## Links

- npm: https://www.npmjs.com/package/shake2.js
- Repository: https://github.com/Losnen/shake
- Homepage: https://github.com/Losnen/shake#readme
- Issues: https://github.com/Losnen/shake/issues
- npm.io page: https://npm.io/package/shake2.js

## Recent versions

- 1.0.1 (latest) — 2018-10-17
- 1.0.0 — 2018-10-17

## README

# Shake.js

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

## Installation

* [NPM](https://www.npmjs.com/package/shake2.js): `npm install shake2.js`

## Dependencies

Your web browser must support the `devicemotion` event for this plugin to work. Shake.js uses built-in feature detection to determine if it can run in your web browser. It will terminate silently on non-supporting browsers.

* [DeviceOrientation Event Specification](https://w3c.github.io/deviceorientation/)

## Setup

### For CommonJS using NPM:

```javascript
const Shake = require('shake2.js');
```

### For ES6 Import using NPM:

```javascript
import Shake from 'shake2.js';
```

### In the browser:

```html
<script src="./node_modules/shake2.js/dist/index.js"></script>
```

### Use
```javascript
// Create an instance
const myShakeEvent = new Shake({
    threshold: 15, // optional shake strength threshold
    timeout: 1000 // optional, determines the frequency of event generation
});

// Start listening to device motion:
myShakeEvent.start();

// Register a `shake` event listener on `window` with your callback:
window.addEventListener('shake', shakeEventDidOccur, false);

// Dunction to call when shake event occurs
function shakeEventDidOccur () {
    // Do something awesome!
}

// You can stop listening for shake events like so:
window.removeEventListener('shake', shakeEventDidOccur, false);

// To stop listening to device motion, you can call:
myShakeEvent.stop();
```

## Supported web browsers/devices


- iOS Safari 4.2.1 (and above)
- Android 4.0.3 (default browser)
- Chrome 41+ for Android
- Opera Mobile (Android)
- BlackBerry PlayBook 2.0
- Firefox for Android
- FirefoxOS Devices

---
_Source: https://npm.io/package/shake2.js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
