You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/10/22 02:12:17 UTC

[5/6] git commit: fix acceleromter for firefox os

fix acceleromter for firefox os


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/commit/015e3f9b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/tree/015e3f9b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/diff/015e3f9b

Branch: refs/heads/dev
Commit: 015e3f9b134849f29af08aca54cb1adf701bda41
Parents: fcc626a
Author: James Long <lo...@gmail.com>
Authored: Mon Oct 21 17:47:05 2013 -0400
Committer: James Long <lo...@gmail.com>
Committed: Mon Oct 21 17:47:05 2013 -0400

----------------------------------------------------------------------
 src/firefoxos/accelerometer.js | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/015e3f9b/src/firefoxos/accelerometer.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/accelerometer.js b/src/firefoxos/accelerometer.js
index 5ba0b7d..d2fa658 100644
--- a/src/firefoxos/accelerometer.js
+++ b/src/firefoxos/accelerometer.js
@@ -1,15 +1,15 @@
 
 var Accelerometer = {
-    start: function start(successCallback, errorCallback) {
-        console.log('start watching accelerometer');
-        function accelerationCallback(deviceMotionEvent) {
-            successCallback(deviceMotionEvent.acceleration);
-        }
-        return document.addEventListener('devicemotion', accelerationCallback, false);
+    start: function start(success, error) {
+        return window.addEventListener('devicemotion', function(ev) {
+            var acc = ev.accelerationIncludingGravity;
+            acc.timestamp = new Date().getTime();
+            success(ev.accelerationIncludingGravity);
+        }, false);
     },
-    stop: function stop(watchId) {
-        console.log('stop watching acecelerometer');
-        document.removeEventListener('devicemotion', watchId);
+
+    stop: function stop() {
+        window.removeEventListener('devicemotion');
     }
 };