https://github.com/pirxpilot/kompas
Calculates heading based on "deviceorientation" event.
https://github.com/pirxpilot/kompas
Last synced: 12 months ago
JSON representation
Calculates heading based on "deviceorientation" event.
- Host: GitHub
- URL: https://github.com/pirxpilot/kompas
- Owner: pirxpilot
- Created: 2018-10-22T16:20:10.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2025-06-13T00:55:08.000Z (about 1 year ago)
- Last Synced: 2025-06-13T01:43:09.518Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 21.5 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
[![NPM version][npm-image]][npm-url]
[![Build Status][build-image]][build-url]
[![Dependency Status][deps-image]][deps-url]
# kompas
Calculates heading based on `deviceorientation` event.
The algorithm is a version proposed in the [stackoverflow answer] and [deviceorientation spec] modified for [chrome].
Check out [demo] page to see how it works on your device.
## Install
```sh
$ npm install --save kompas
```
## Usage
```js
const kompas = require('kompas');
// start watching and add callback
kompas.watch();
kompas.on('heading', function(heading) {
console.log('Heading:', heading);
});
// stop watching
kompas.clear();
```
## License
MIT © [Damian Krzeminski](https://pirxpilot.me)
[demo]: https://pirxpilot.github.io/kompas/
[stackoverflow answer]: https://stackoverflow.com/questions/18112729/calculate-kompas-from-deviceorientation-event-api#21829819
[deviceorientation spec]: https://w3c.github.io/deviceorientation/#worked-example
[chrome]: https://developers.google.com/web/updates/2016/03/device-orientation-changes
[npm-image]: https://img.shields.io/npm/v/kompas
[npm-url]: https://npmjs.org/package/kompas
[build-url]: https://github.com/pirxpilot/kompas/actions/workflows/check.yaml
[build-image]: https://img.shields.io/github/actions/workflow/status/pirxpilot/kompas/check.yaml?branch=main
[deps-image]: https://img.shields.io/librariesio/release/npm/kompas
[deps-url]: https://libraries.io/npm/kompas