Created
August 6, 2012 16:50
-
-
Save apeckham/3276533 to your computer and use it in GitHub Desktop.
emulate devicemotion event using phonegap's watchAcceleration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on({ | |
deviceready: function () { | |
if (!('ondevicemotion' in window)) { | |
navigator.accelerometer.watchAcceleration(function (acceleration) { | |
var event = document.createEvent('Event'); | |
event.initEvent('devicemotion', true, true); | |
event.accelerationIncludingGravity = acceleration; | |
window.dispatchEvent(event); | |
}, $.noop, {frequency: 250}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment