incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [5/45] js commit: update Accelerometer to install itself with commandProxy
Date Sat, 06 Oct 2012 09:19:20 GMT
update Accelerometer to install itself with commandProxy


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

Branch: refs/heads/master
Commit: 8ff53d5412058925a13f7125361aacde4649e0f5
Parents: 0d58bf4
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Fri Oct 5 17:12:03 2012 -0700
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Fri Oct 5 17:12:03 2012 -0700

----------------------------------------------------------------------
 lib/windows8/plugin/windows8/AccelerometerProxy.js |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8ff53d54/lib/windows8/plugin/windows8/AccelerometerProxy.js
----------------------------------------------------------------------
diff --git a/lib/windows8/plugin/windows8/AccelerometerProxy.js b/lib/windows8/plugin/windows8/AccelerometerProxy.js
index c1cd57f..91916b0 100644
--- a/lib/windows8/plugin/windows8/AccelerometerProxy.js
+++ b/lib/windows8/plugin/windows8/AccelerometerProxy.js
@@ -33,7 +33,7 @@ module.exports = {
 
         var accel = Windows.Devices.Sensors.Accelerometer.getDefault();
         if(!accel) {
-            lose("No accelerometer found");
+            lose && lose("No accelerometer found");
         }
         else {
             var self = this;
@@ -45,13 +45,17 @@ module.exports = {
                 win(new Acceleration(a.accelerationX,a.accelerationY,a.accelerationZ));
             };
             accel.addEventListener("readingchanged",this.onDataChanged);
+
+            setTimeout(function(){
+                var a = accel.getCurrentReading();
+                win(new Acceleration(a.accelerationX,a.accelerationY,a.accelerationZ));
+            },0); // async do later
         }
     },
     stop:function(win,lose){
-        console.log("Accelerometer.stop");
         var accel = Windows.Devices.Sensors.Accelerometer.getDefault();
         if(!accel) {
-            lose("No accelerometer found");
+            lose && lose("No accelerometer found");
         }
         else {
             accel.removeEventListener("readingchanged",this.onDataChanged);
@@ -61,3 +65,5 @@ module.exports = {
         }
     }
 };
+
+require("cordova/commandProxy").add("Accelerometer",module.exports);
\ No newline at end of file


Mime
View raw message