[OpenLayers-Commits] r11323 - in sandbox/sbrunner/openlayers: examples lib/OpenLayers/Control

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Feb 23 09:13:37 EST 2011


Author: fredj
Date: 2011-02-23 06:13:37 -0800 (Wed, 23 Feb 2011)
New Revision: 11323

Modified:
   sandbox/sbrunner/openlayers/examples/orientation.html
   sandbox/sbrunner/openlayers/lib/OpenLayers/Control/DeviceOrientation.js
Log:
only activate if supported

Modified: sandbox/sbrunner/openlayers/examples/orientation.html
===================================================================
--- sandbox/sbrunner/openlayers/examples/orientation.html	2011-02-23 14:10:39 UTC (rev 11322)
+++ sandbox/sbrunner/openlayers/examples/orientation.html	2011-02-23 14:13:37 UTC (rev 11323)
@@ -20,12 +20,12 @@
         orientation = new OpenLayers.Control.DeviceOrientation();
         if (orientation.supported()) {
             orientation.events.register("orientationchange", this, function(event) {
+                logs.innerHTML = "rotation: " + event.orientation;
+
                 var img = document.getElementById("orientation");
                 var value = "rotate(" + event.orientation + "deg)";
                 img.style.transform = value;
                 img.style.webkitTransform = value;
-                
-                logs.innerHTML = "rotation: " + event.orientation;
             });
             orientation.activate();
         } else {

Modified: sandbox/sbrunner/openlayers/lib/OpenLayers/Control/DeviceOrientation.js
===================================================================
--- sandbox/sbrunner/openlayers/lib/OpenLayers/Control/DeviceOrientation.js	2011-02-23 14:10:39 UTC (rev 11322)
+++ sandbox/sbrunner/openlayers/lib/OpenLayers/Control/DeviceOrientation.js	2011-02-23 14:13:37 UTC (rev 11323)
@@ -55,7 +55,7 @@
      * {Boolean} The control was effectively activated.
      */
     activate: function() {
-        if (!this.active) {
+        if (!this.active && this.supported()) {
             window.addEventListener("deviceorientation",
                     OpenLayers.Function.bind(this.onOrientation, this), true);
         }



More information about the Commits mailing list