cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pplaque...@apache.org
Subject [01/21] js commit: [Tizen, Tizen SDK 2.0 (Magnolia)] - Accelerometer
Date Fri, 17 May 2013 14:22:11 GMT
Updated Branches:
  refs/heads/master 1a148c0af -> ac7968e9e


[Tizen, Tizen SDK 2.0 (Magnolia)] - Accelerometer

Adapt Accelerometer, namespace, variables names, cleanup


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/34156064
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/34156064
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/34156064

Branch: refs/heads/master
Commit: 34156064546ff2bdefc76daa2b4aa910a0e4297f
Parents: d263377
Author: pplaquette <pplaquette@apache.org>
Authored: Wed Apr 17 11:12:55 2013 +0200
Committer: pplaquette <pplaquette@apache.org>
Committed: Fri Apr 19 11:07:13 2013 +0200

----------------------------------------------------------------------
 lib/tizen/plugin/tizen/Accelerometer.js |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/34156064/lib/tizen/plugin/tizen/Accelerometer.js
----------------------------------------------------------------------
diff --git a/lib/tizen/plugin/tizen/Accelerometer.js b/lib/tizen/plugin/tizen/Accelerometer.js
index ef903f3..f6d6d20 100644
--- a/lib/tizen/plugin/tizen/Accelerometer.js
+++ b/lib/tizen/plugin/tizen/Accelerometer.js
@@ -19,22 +19,29 @@
  *
 */
 
-var callback = null;
+var accelerometerCallback = null;
 
 module.exports = {
+
     start: function (successCallback, errorCallback) {
-        window.removeEventListener("devicemotion", callback);
-        callback = function (motion) {
+
+        if (accelerometerCallback) {
+            window.removeEventListener("devicemotion", accelerometerCallback, true);
+        }
+
+        accelerometerCallback = function (motion) {
             successCallback({
                 x: motion.accelerationIncludingGravity.x,
                 y: motion.accelerationIncludingGravity.y,
                 z: motion.accelerationIncludingGravity.z,
-                timestamp: motion.timeStamp
+                timestamp: motion.interval
             });
         };
-        window.addEventListener("devicemotion", callback);
+        window.addEventListener("devicemotion", accelerometerCallback, true);
     },
+
     stop: function (successCallback, errorCallback) {
-        window.removeEventListener("devicemotion", callback);
+        window.removeEventListener("devicemotion", accelerometerCallback, true);
+        accelerometerCallback = null;
     }
 };


Mime
View raw message