1 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
2 //>>description: Fixes the orientation change bug in iOS when switching between landspace and portrait
3 //>>label: iOS Orientation Change Fix
6 define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.zoom" ], function( $ ) {
7 //>>excludeEnd("jqmBuildExclude");
8 ( function( $, window ) {
10 // This fix addresses an iOS bug, so return early if the UA claims it's something else.
11 if( !(/iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1 ) ){
15 var zoom = $.mobile.zoom,
18 function checkTilt( e ){
19 evt = e.originalEvent;
20 aig = evt.accelerationIncludingGravity;
22 x = Math.abs( aig.x );
23 y = Math.abs( aig.y );
24 z = Math.abs( aig.z );
26 // If portrait orientation and in one of the danger zones
27 if( !window.orientation && ( x > 7 || ( ( z > 6 && y < 8 || z < 8 && y > 6 ) && x > 5 ) ) ){
32 else if( !zoom.enabled ){
38 .bind( "orientationchange.iosorientationfix", zoom.enable )
39 .bind( "devicemotion.iosorientationfix", checkTilt );
42 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
44 //>>excludeEnd("jqmBuildExclude");