Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/topheman/sensorschecker.js
Mostly all recent browsers expose an api for deviceorientation and devicemotion events. This module will let you check if there is really an accelerometer+gyroscope to rely on.
https://github.com/topheman/sensorschecker.js
Last synced: about 2 months ago
JSON representation
Mostly all recent browsers expose an api for deviceorientation and devicemotion events. This module will let you check if there is really an accelerometer+gyroscope to rely on.
- Host: GitHub
- URL: https://github.com/topheman/sensorschecker.js
- Owner: topheman
- License: mit
- Created: 2014-04-07T13:39:28.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-05-13T16:38:13.000Z (over 6 years ago)
- Last Synced: 2024-11-07T13:56:22.598Z (about 2 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 5
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
sensorsChecker.js
=================[![npm version](https://badge.fury.io/js/sensors-checker.svg)](https://www.npmjs.com/package/sensors-checker)
Mostly all recent browsers expose an api for `deviceorientation` and `devicemotion` events.
* That doesn't mean the device you're on has sensors (accelerometer+gyroscope) to feed them.
* So, to check if the device has sensors, you can't rely on simple feature detection like `"ondeviceorientation" in window` or `"ondevicemotion" in window`
* This module will let you check if there is really an accelerometer+gyroscope to rely on.```js
//check the sensors for the deviceorientation api
sensorsChecker.checkDeviceorientation(function(){
console.log('sensors detected');
},function(){
console.error('no sensor detected');
}
);
//check the sensors for the devicemotion api (this time with some options)
sensorsChecker.checkDevicemotion(function(){
console.log('sensors detected');
},function(){
console.error('no sensor detected');
},{
userAgentCheck: /(iPad|iPhone|Nexus|Mobile|Tablet)/i,//@optional (to bypass the sniffing)
delay: 600//@optional default delay : 500ms
}
);
```Used in :
* https://github.com/topheman/PanoramaSensorsViewer
* http://streetview.topheman.com
* https://github.com/topheman/bombs
* https://github.com/topheman/playground2 (finally, no need for, according to the UX)Now available on npm: `npm install sensors-checker --save`