cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [10/26] js commit: [Tizen, Tizen SDK 2.0 (Magnolia)]
Date Fri, 17 May 2013 17:53:28 GMT
[Tizen, Tizen SDK 2.0 (Magnolia)]

Adapt to new SDK
using CompassHeading object , and constructor
plus cleaning, a few renamings


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

Branch: refs/heads/3.0.0
Commit: 3a386e57c9365bd72d1cd2faf3687a7402b2182a
Parents: c139ba0
Author: pplaquette <pplaquette@apache.org>
Authored: Wed Apr 17 11:23:22 2013 +0200
Committer: pplaquette <pplaquette@apache.org>
Committed: Fri Apr 19 11:07:14 2013 +0200

----------------------------------------------------------------------
 lib/tizen/plugin/tizen/Compass.js |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/3a386e57/lib/tizen/plugin/tizen/Compass.js
----------------------------------------------------------------------
diff --git a/lib/tizen/plugin/tizen/Compass.js b/lib/tizen/plugin/tizen/Compass.js
index 74cb48e..b7fd029 100644
--- a/lib/tizen/plugin/tizen/Compass.js
+++ b/lib/tizen/plugin/tizen/Compass.js
@@ -20,26 +20,27 @@
 */
 
 var CompassError = require('cordova/plugin/CompassError'),
-    callback = null, ready = false;
+    CompassHeading = require('cordova/plugin/CompassHeadings');
+
+var compassCallback = null,
+    compassReady = false;
 
 module.exports = {
     getHeading: function(successCallback, errorCallback) {
+
         if (window.DeviceOrientationEvent !== undefined) {
-            callback = function (orientation) {
+
+            compassCallback = function (orientation) {
                 var heading = 360 - orientation.alpha;
-                if (ready) {
-                    successCallback({
-                        magneticHeading: heading,
-                        trueHeading: heading,
-                        headingAccuracy: 0,
-                        timestamp: orientation.timeStamp
-                    });
-                    window.removeEventListener("deviceorientation", callback);
+
+                if (compassReady) {
+                    successCallback( new CompassHeading (heading, heading, 0, 0));
+                    window.removeEventListener("deviceorientation", compassCallback, true);
                 }
-                ready = true;
+                compassReady = true;
             };
-            ready = false; // workaround invalid first event value returned by WRT
-            window.addEventListener("deviceorientation", callback);
+            compassReady = false; // workaround invalid first event value returned by WRT
+            window.addEventListener("deviceorientation", compassCallback, true);
         }
         else {
             errorCallback(CompassError.COMPASS_NOT_SUPPORTED);


Mime
View raw message