PageSourceSearch

https://www.freshwatersacademy.org/inc/modules/home_header/js/mobile-chrome-vh-fix.js

js freshwatersacademy.org collected 2026-09-29 11:29:00 UTC 2,427 bytes, 65 lines download raw bytes

1var VHChromeFix = function(selectors) {
2    var self = this;
3    var userAgent = navigator.userAgent.toLowerCase();
4    var isAndroidChrome = /chrome/.test(userAgent) && /android/.test(userAgent);
5    var isIOSChrome = /crios/.test(userAgent);
6
7    if (isAndroidChrome || isIOSChrome) {
8        // If we detected Chrome on Android or iOS
9        // Cache elements and trigger fix on init
10        this.getElements(selectors);
11        this.fixAll();
12
13        // Cache window dimensions
14        this.windowWidth = window.innerWidth;
15        this.windowHeight = window.innerHeight;
16
17        window.addEventListener('resize', function() {
18            // Both width and height changed (orientation change)
19            // This is a hack, as Android when eyboard pops up
20            // Triggers orientation change
21            if (self.windowWidth !== window.innerWidth && self.windowHeight !== window.innerHeight) {
22                self.windowWidth = window.innerWidth;
23                self.windowHeight = window.innerHeight;
24                self.fixAll();
25            }
26        });
27    }
28};
29
30VHChromeFix.prototype.getElements = function(selectors) {
31    this.elements = [];
32    // Convert selectors to array if they are not
33    selectors = this.isArray(selectors) ? selectors : [selectors];
34
35    for (var i = 0; i < selectors.length; i++) {
36        // Get all elements for selector
37        var selector = selectors[i].selector;
38        var elements = document.querySelectorAll(selector);
39
40        // Go through all elements for one selector to filter them
41        for (var j = 0; j < elements.length; j++) {
42            this.elements.push({
43                domElement: elements[j],
44                vh: selectors[i].vh,
45                neg: selectors[i].neg
46            });
47        }
48    }
49};
50
51VHChromeFix.prototype.isArray = function(array) {
52    return Object.prototype.toString.call(array) === '[object Array]';
53};
54
55VHChromeFix.prototype.fixAll = function() {
56    for (var i = 0; i < this.elements.length; i++) {
57        var element = this.elements[i];
58        var neg = this.elements[i].neg;
59        if (typeof neg != 'undefined' && neg) {
60            element.domElement.style.height = (window.innerHeight * element.vh / 100)-neg + 'px';
61        }else{
62            element.domElement.style.height = (window.innerHeight * element.vh / 100) + 'px';
63        }
64    }
65};

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.