From 6cee30d22c7f907141e396da6171ab709e01880a Mon Sep 17 00:00:00 2001 From: scottjehl Date: Fri, 20 Jan 2012 23:20:27 +0700 Subject: [PATCH] updated to use only the devicemotion event, for compatibility and less battery battering --- js/jquery.mobile.zoom.iosorientationfix.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/js/jquery.mobile.zoom.iosorientationfix.js b/js/jquery.mobile.zoom.iosorientationfix.js index 077b8610..847d22be 100644 --- a/js/jquery.mobile.zoom.iosorientationfix.js +++ b/js/jquery.mobile.zoom.iosorientationfix.js @@ -6,22 +6,17 @@ define( [ "jquery", "jquery.mobile.core", "jquery.mobile.zoom" ], function( $ ) //>>excludeEnd("jqmBuildExclude"); ( function( $, window ) { var zoom = $.mobile.zoom, - rotation = 0, - x = y = z = 0, - orientation, aig; + x, y, z, aig; function checkTilt( e ){ evt = e.originalEvent; - orientation = window.orientation; aig = evt.accelerationIncludingGravity; - - if( aig ){ - x = Math.abs( aig.x ); - y = Math.abs( aig.y ); - z = Math.abs( aig.z ); - } - if( orientation === 0 && ( e.type === "deviceorientation" || x > 7 || ( z > 4 && ( x > 6 || y > 6 ) ) ) ){ + x = Math.abs( aig.x ); + y = Math.abs( aig.y ); + z = Math.abs( aig.z ); + + if( !window.orientation && ( x > 8.1 || ( ( z > 6.5 || y > 6.5 ) && x > 5.5 ) ) ){ if( zoom.enabled ){ zoom.disable(); } @@ -33,7 +28,7 @@ define( [ "jquery", "jquery.mobile.core", "jquery.mobile.zoom" ], function( $ ) $( window ) .bind( "orientationchange", zoom.enable ) - .bind( "deviceorientation devicemotion", checkTilt ); + .bind( "devicemotion", checkTilt ); }( jQuery, this )); //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);