This change brings the iOS orientationchange bug workaround up to the latest code from that external project, with an experimental attempt at iOS4.3 support on the 3GS using the devicemotion event, which may be a bad idea to use unthrottled - not sure yet. This code needs to be tested on a device with iOS5, and I imagine the check for deviceorientation will also need a check for the value of evt.gamma. At that point, we may decide to only support iOS5 for this workaround, and the code can bind only to deviceorientation and be more concise.

This commit is contained in:
scottjehl 2012-01-19 20:59:21 +07:00
parent 4e2c8ef2a3
commit 460ad7197c

View file

@ -5,29 +5,35 @@
define( [ "jquery", "jquery.mobile.core", "jquery.mobile.zoom" ], function( $ ) {
//>>excludeEnd("jqmBuildExclude");
( function( $, window ) {
var orientation = window.orientation,
rotation = 0;
var zoom = $.mobile.zoom,
rotation = 0,
x = y = z = 0,
orientation, aig;
function checkTilt( e ){
e = e.originalEvent;
orientation = Math.abs( window.orientation );
rotation = Math.abs( e.gamma );
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( rotation > 8 && orientation === 0 ){
if( $.mobile.zoom.enabled ){
$.mobile.zoom.disable();
}
if( orientation === 0 && ( e.type === "deviceorientation" || x > 7 || ( z > 4 && ( x > 6 || y > 6 ) ) ) ){
if( zoom.enabled ){
zoom.disable();
}
}
else {
if( !$.mobile.zoom.enabled ){
$.mobile.zoom.enable();
}
else if( !zoom.enabled ){
zoom.enable();
}
}
$( window )
.bind( "orientationchange", $.mobile.zoom.enable )
.bind( "deviceorientation", checkTilt );
.bind( "orientationchange", zoom.enable )
.bind( "deviceorientation devicemotion", checkTilt );
}( jQuery, this ));
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);