cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [10/19] git commit: fix acceleromter for firefox os
Date Mon, 28 Oct 2013 22:11:47 GMT
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/master
Commit: 015e3f9b134849f29af08aca54cb1adf701bda41
Parents: fcc626a
Author: James Long <longster@gmail.com>
Authored: Mon Oct 21 17:47:05 2013 -0400
Committer: James Long <longster@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');
     }
 };
 


Mime
View raw message