Releases: play-co/accelerometer
Releases · play-co/accelerometer
rotationRate fixes
v3.0.0: switch to devicemotion events
Summary
accelerometer
plugin emitsdevicemotion
events with same motion event api as an HTML5 browser on all platforms- fixes incompatibilities between native and mobile browsers, namely:
- mobile Safari (iOS): acceleration values are inverted (relative to other platforms)
- iOS native: acceleration values are scaled by -9.8 (relative to other platforms)
- also exposes native APIs over
window.addEventListener
for compatibility (existing html5 browser code can run unmodified on native), but this is not recommended for new code since direct use of theaccelerometer
plugin API avoids browser differences
Usage
-
place the import at the top of your
Application.js
:import accelerometer;
-
use the
devicemotion
event:accelerometer.on('devicemotion', function (evt) { // these values should be identical on all devices evt.acceleration.x... });
-
(not recommended, but supported for compatibility) native DOM API
window.addEventListener
:window.addEventListener('devicemotion', function (evt) { // WARNING: these values will not be the same in all browsers. Use the devkit // accelerometer api directly for consistent values. evt.acceleration.x... });
-
event objects have the following properties:
evt.acceleration.x evt.acceleration.y evt.acceleration.z evt.accelerationIncludingGravity.x evt.accelerationIncludingGravity.y evt.accelerationIncludingGravity.z evt.rotationRate.alpha evt.rotationRate.beta evt.rotationRate.gamma
Devkit2 Support
Initial commit with DevKit2 Support
Devkit1 Support
Last commit from master before switching to DevKit2