1 |
74f6bef0
|
Assos Assos
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
(function(w){
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
var ua = navigator.userAgent;
|
9 |
|
|
if( !( /iPhone|iPad|iPod/.test( navigator.platform ) && /OS [1-5]_[0-9_]* like Mac OS X/i.test(ua) && ua.indexOf( "AppleWebKit" ) > -1 ) ){
|
10 |
|
|
return;
|
11 |
|
|
}
|
12 |
|
|
|
13 |
|
|
var doc = w.document;
|
14 |
|
|
|
15 |
|
|
if( !doc.querySelector ){ return; }
|
16 |
|
|
|
17 |
|
|
var meta = doc.querySelector( "meta[name=viewport]" ),
|
18 |
|
|
initialContent = meta && meta.getAttribute( "content" ),
|
19 |
|
|
disabledZoom = initialContent + ",maximum-scale=1",
|
20 |
|
|
enabledZoom = initialContent + ",maximum-scale=10",
|
21 |
|
|
enabled = true,
|
22 |
|
|
x, y, z, aig;
|
23 |
|
|
|
24 |
|
|
if( !meta ){ return; }
|
25 |
|
|
|
26 |
|
|
function restoreZoom(){
|
27 |
|
|
meta.setAttribute( "content", enabledZoom );
|
28 |
|
|
enabled = true;
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
function disableZoom(){
|
32 |
|
|
meta.setAttribute( "content", disabledZoom );
|
33 |
|
|
enabled = false;
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
function checkTilt( e ){
|
37 |
|
|
aig = e.accelerationIncludingGravity;
|
38 |
|
|
x = Math.abs( aig.x );
|
39 |
|
|
y = Math.abs( aig.y );
|
40 |
|
|
z = Math.abs( aig.z );
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
if( (!w.orientation || w.orientation === 180) && ( x > 7 || ( ( z > 6 && y < 8 || z < 8 && y > 6 ) && x > 5 ) ) ){
|
44 |
|
|
if( enabled ){
|
45 |
|
|
disableZoom();
|
46 |
|
|
}
|
47 |
|
|
}
|
48 |
|
|
else if( !enabled ){
|
49 |
|
|
restoreZoom();
|
50 |
|
|
}
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
w.addEventListener( "orientationchange", restoreZoom, false );
|
54 |
|
|
w.addEventListener( "devicemotion", checkTilt, false );
|
55 |
|
|
|
56 |
|
|
})( this ); |