You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sg...@apache.org on 2015/03/06 12:14:01 UTC

cordova-plugin-device-orientation git commit: CB-8614 Fixed getCurrentHeading and watchHeading on windows platform

Repository: cordova-plugin-device-orientation
Updated Branches:
  refs/heads/master 904504f1b -> 1358eb869


CB-8614 Fixed getCurrentHeading and watchHeading on windows platform

github close #18


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/commit/1358eb86
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/tree/1358eb86
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/diff/1358eb86

Branch: refs/heads/master
Commit: 1358eb869f6bfa803b54ad89cfd52d354252792e
Parents: 904504f
Author: alsorokin <al...@akvelon.com>
Authored: Thu Mar 5 14:59:53 2015 +0300
Committer: sgrebnov <v-...@microsoft.com>
Committed: Fri Mar 6 14:13:51 2015 +0300

----------------------------------------------------------------------
 src/windows8/CompassProxy.js | 25 ++++---------------------
 1 file changed, 4 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation/blob/1358eb86/src/windows8/CompassProxy.js
----------------------------------------------------------------------
diff --git a/src/windows8/CompassProxy.js b/src/windows8/CompassProxy.js
index cac3f49..a9ad68d 100644
--- a/src/windows8/CompassProxy.js
+++ b/src/windows8/CompassProxy.js
@@ -37,30 +37,13 @@ module.exports = {
                 lose(CompassError.COMPASS_NOT_SUPPORTED);
             }, 0);
         } else {
-
-            deviceCompass.reportInterval = Math.max(16, deviceCompass.minimumReportInterval);
-
-            this.onReadingChanged = function (e) {
-                var reading = e.reading,
-                    heading = new CompassHeading(reading.headingMagneticNorth, reading.headingTrueNorth, null, reading.timestamp.getTime());
-                win(heading);
-            };
-            deviceCompass.addEventListener("readingchanged", this.onReadingChanged);
+            var reading = deviceCompass.getCurrentReading(),
+                heading = new CompassHeading(reading.headingMagneticNorth, reading.headingTrueNorth, null, reading.timestamp.getTime());
+            win(heading);
         }
     },
     stopHeading: function (win, lose) {
-        var deviceCompass = Windows.Devices.Sensors.Compass.getDefault();
-        if (!deviceCompass) {
-            setTimeout(function () {
-                lose(CompassError.COMPASS_NOT_SUPPORTED);
-            }, 0);
-        } else {
-            deviceCompass.removeEventListener("readingchanged", this.onReadingChanged);
-            this.onReadingChanged = null;
-            deviceCompass.reportInterval = 0;
-            win();
-        }
-
+        win();
     }
 };
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org