|
5 | 5 | define( [ "jquery", "jquery.mobile.core", "jquery.mobile.zoom" ], function( $ ) {
|
6 | 6 | //>>excludeEnd("jqmBuildExclude");
|
7 | 7 | ( function( $, window ) {
|
8 |
| - var orientation = window.orientation, |
9 |
| - rotation = 0; |
10 |
| - |
| 8 | + var zoom = $.mobile.zoom, |
| 9 | + rotation = 0, |
| 10 | + x = y = z = 0, |
| 11 | + orientation, aig; |
| 12 | + |
11 | 13 | function checkTilt( e ){
|
12 |
| - e = e.originalEvent; |
13 |
| - orientation = Math.abs( window.orientation ); |
14 |
| - rotation = Math.abs( e.gamma ); |
| 14 | + evt = e.originalEvent; |
| 15 | + orientation = window.orientation; |
| 16 | + aig = evt.accelerationIncludingGravity; |
| 17 | + |
| 18 | + if( aig ){ |
| 19 | + x = Math.abs( aig.x ); |
| 20 | + y = Math.abs( aig.y ); |
| 21 | + z = Math.abs( aig.z ); |
| 22 | + } |
15 | 23 |
|
16 |
| - if( rotation > 8 && orientation === 0 ){ |
17 |
| - if( $.mobile.zoom.enabled ){ |
18 |
| - $.mobile.zoom.disable(); |
19 |
| - } |
| 24 | + if( orientation === 0 && ( e.type === "deviceorientation" || x > 7 || ( z > 4 && ( x > 6 || y > 6 ) ) ) ){ |
| 25 | + if( zoom.enabled ){ |
| 26 | + zoom.disable(); |
| 27 | + } |
20 | 28 | }
|
21 |
| - else { |
22 |
| - if( !$.mobile.zoom.enabled ){ |
23 |
| - $.mobile.zoom.enable(); |
24 |
| - } |
| 29 | + else if( !zoom.enabled ){ |
| 30 | + zoom.enable(); |
25 | 31 | }
|
26 | 32 | }
|
27 | 33 |
|
28 | 34 | $( window )
|
29 |
| - .bind( "orientationchange", $.mobile.zoom.enable ) |
30 |
| - .bind( "deviceorientation", checkTilt ); |
| 35 | + .bind( "orientationchange", zoom.enable ) |
| 36 | + .bind( "deviceorientation devicemotion", checkTilt ); |
31 | 37 |
|
32 | 38 | }( jQuery, this ));
|
33 | 39 | //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
|
|
0 commit comments