Skip to content

Commit

Permalink
docs: update example and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
evanshortiss committed Feb 18, 2019
1 parent b6b9d7e commit e69f730
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,30 @@ orientation event is captured is used as alpha of 0. This is only necessary on A

Behaviour like this can be made configurable through options in the future.

## Example

To try the example application do the following:

```
git clone https://github.com/evanshortiss/webmo.git
cd webmo
npm i
npm start
```

Now visit port 8080 using a device that supports motion and orientation, for example a modern mobile phone, and you'll see live data from the sensors.

## API

### webmo.motion

All motion related functions fall under this namespace.

### webmo.motion.mayHaveMotionSupport()
### webmo.motion.mayHaveMotionSupport(): boolean

Returns `true` if `DeviceMotionEvent` is available.

### webmo.motion.deviceHasMotionSupport(timeout: number): Promise<boolean>
### webmo.motion.deviceHasMotionSupport(timeout: number): Promise\<boolean>

Tests for motion support by detecting motion events. Defaults to a 1000 millisecond timeout before resolving with `false`. Resolves with `true` if a motion event is detected before `timeout` is reached.

Expand Down Expand Up @@ -86,7 +99,7 @@ Stop listening for motion events.

Changes the threshold required for this instance to consider a motion event worth emitting.

#### webmo.motion.MotionListener.isListening()
#### webmo.motion.MotionListener.isListening(): boolean

Returns `true` if the instance is listening for motion events.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Device motion and orientation capture library with TypeScript support.",
"main": "src/index.js",
"scripts": {
"serve:example": "npm run build:browser && cp dist/webmo.js example/ && http-server example/",
"start": "npm run build:browser && cp dist/webmo.js example/ && http-server example/",
"build:tsc": "tsc",
"build:browser": "npm run build:tsc && browserify -s webmo -e src/index.js -o dist/webmo.js && uglifyjs -cm -o dist/webmo.min.js dist/webmo.js",
"format": "prettier --fix --single-quote src/*.ts --write",
Expand Down

0 comments on commit e69f730

Please sign in to comment.