iou90 před 5 roky
rodič
revize
0a9fc24017
1 změnil soubory, kde provedl 2 přidání a 3 odebrání
  1. 2
    3
      autoHeightWebView/utils.js

+ 2
- 3
autoHeightWebView/utils.js Zobrazit soubor

14
 
14
 
15
 const updateSizeWithMessage = (element, scalesPageToFit) =>
15
 const updateSizeWithMessage = (element, scalesPageToFit) =>
16
   `
16
   `
17
-  var scale = ${scalesPageToFit ? 'screen.width / window.innerWidth' : '1'};
18
   var lastHeight = 0;
17
   var lastHeight = 0;
19
   var heightTheSameTimes = 0;
18
   var heightTheSameTimes = 0;
20
   var maxHeightTheSameTimes = 5;
19
   var maxHeightTheSameTimes = 5;
33
     clearTimeout(checkPostMessageTimeout);
32
     clearTimeout(checkPostMessageTimeout);
34
     height = ${element}.offsetHeight || document.documentElement.offsetHeight;
33
     height = ${element}.offsetHeight || document.documentElement.offsetHeight;
35
     width = ${element}.offsetWidth || document.documentElement.offsetWidth;
34
     width = ${element}.offsetWidth || document.documentElement.offsetWidth;
36
-    var needScale = width > screen.width;
37
-    window.ReactNativeWebView.postMessage(JSON.stringify({ width: needScale ? width * scale : width, height: needScale ? height * scale : height }));
35
+    var scale = ${scalesPageToFit ? 'screen.width / window.innerWidth' : '1'};
36
+    window.ReactNativeWebView.postMessage(JSON.stringify({ width: Math.min(width, screen.width), height: height * scale }));
38
 
37
 
39
     // Make additional height checks (required to fix issues wit twitter embeds)
38
     // Make additional height checks (required to fix issues wit twitter embeds)
40
     clearTimeout(forceRefreshTimeout);
39
     clearTimeout(forceRefreshTimeout);