summaryrefslogtreecommitdiffstats
path: root/browser/extensions/webcompat/injections/js/bug1855071-www.meteoam.it.js
blob: 2bf38345dca17e16740726219cdb1cfe51950edf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

/**
 * www.meteoam.it - virtual keyboard is hidden as it is opened
 * webcompat issue #121197 - https://webcompat.com/issues/121197
 *
 * the site's map is 75vh tall, and it hides the keyboard onresize,
 * meaning the keyboard is closed as it it brought up in Firefox.
 */

console.info(
  "Map iframe height is being managed for compatibility reasons. see https://webcompat.com/issues/77221 for details."
);

const selector = "#iframe_map";

const moOptions = {
  childList: true,
  subtree: true,
};

const mo = new MutationObserver(() => {
  const map = document.querySelector(selector);
  let lastSize;
  if (map) {
    mo.disconnect();
    const maybeGrowMap = () => {
      const winHeight = window.outerHeight;
      if (lastSize && lastSize > winHeight) {
        return;
      }
      map.style.height = winHeight * 0.75 + "px";
      lastSize = winHeight;
    };
    maybeGrowMap();
    window.addEventListener("resize", () =>
      window.requestAnimationFrame(maybeGrowMap)
    );
  }
});

mo.observe(document.documentElement, moOptions);