PageSourceSearch

https://catalystawards.org/wp-content/themes/vertoh-child/js/vendor/ios-orientationchange-fix.js?ver=7.0.5

js catalystawards.org collected 2026-09-25 04:53:55 UTC 1,701 bytes, 56 lines download raw bytes

1/*! A fix for the iOS orientationchange zoom bug.
2 Script by @scottjehl, rebound by @wilto.
3 MIT / GPLv2 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    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        // If portrait orientation and in one of the danger zones
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 );

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.