PageSourceSearch

https://ieomsociety.org/wp-content/themes/alyeska/framework/fronte…/js/ios-orientationchange-fix.js?ver=7.1.2

js ieomsociety.org collected 2026-09-24 08:42:41 UTC 1,507 bytes, 55 lines download raw bytes

1/*! A fix for the iOS orientationchange zoom bug.
2 Script by @scottjehl, rebound by @wilto.
3 MIT License.
4*/
5(function(w){
6	
7	// This fix addresses an iOS bug, so return early if the UA claims it's something else.
8	if( !( /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1 ) ){
9		return;
10	}
11	
12    var doc = w.document;
13
14    if( !doc.querySelector ){ return; }
15
16    var meta = doc.querySelector( "meta[name=viewport]" ),
17        initialContent = meta && meta.getAttribute( "content" ),
18        disabledZoom = initialContent + ",maximum-scale=1",
19        enabledZoom = initialContent + ",maximum-scale=10",
20        enabled = true,
21		x, y, z, aig;
22
23    if( !meta ){ return; }
24
25    function restoreZoom(){
26        meta.setAttribute( "content", enabledZoom );
27        enabled = true;
28    }
29
30    function disableZoom(){
31        meta.setAttribute( "content", disabledZoom );
32        enabled = false;
33    }
34	
35    function checkTilt( e ){
36		aig = e.accelerationIncludingGravity;
37		x = Math.abs( aig.x );
38		y = Math.abs( aig.y );
39		z = Math.abs( aig.z );
40				
41		// If portrait orientation and in one of the danger zones
42        if( !w.orientation && ( x > 7 || ( ( z > 6 && y < 8 || z < 8 && y > 6 ) && x > 5 ) ) ){
43			if( enabled ){
44				disableZoom();
45			}        	
46        }
47		else if( !enabled ){
48			restoreZoom();
49        }
50    }
51	
52	w.addEventListener( "orientationchange", restoreZoom, false );
53	w.addEventListener( "devicemotion", checkTilt, false );
54
55})( this );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.