Procházet zdrojové kódy

Merge branch 'master' into patch-1

iou90 před 4 roky
rodič
revize
ce39873f8c
No account linked to committer's email address
4 změnil soubory, kde provedl 12 přidání a 16 odebrání
  1. 4
    8
      autoHeightWebView/utils.js
  2. 2
    2
      demo/ios/Podfile.lock
  3. 1
    1
      demo/package.json
  4. 5
    5
      demo/yarn.lock

+ 4
- 8
autoHeightWebView/utils.js Zobrazit soubor

@@ -14,7 +14,7 @@ const domMutationObserveScript = `
14 14
 
15 15
 const updateSizeWithMessage = (element, scalesPageToFit) =>
16 16
   `
17
-  var usingScale = 0;
17
+  var usingScale = ${scalesPageToFit} ? screen.width / window.innerWidth : 1};
18 18
   var scaling = false;
19 19
   var zoomedin = false;
20 20
   var lastHeight = 0;
@@ -25,7 +25,7 @@ const updateSizeWithMessage = (element, scalesPageToFit) =>
25 25
   var checkPostMessageTimeout;
26 26
 
27 27
   function updateSize() {
28
-    if (zoomedin || scaling) {
28
+    if (zoomedin || scaling || document.fullscreenElement) {
29 29
       return;
30 30
     }
31 31
     if (
@@ -40,10 +40,6 @@ const updateSizeWithMessage = (element, scalesPageToFit) =>
40 40
     height = ${element}.offsetHeight || document.documentElement.offsetHeight;
41 41
     width = ${element}.offsetWidth || document.documentElement.offsetWidth;
42 42
 
43
-    if(!usingScale && window.innerWidth) {
44
-      usingScale = ${scalesPageToFit ? 'screen.width / window.innerWidth' : '1'};
45
-    }
46
-
47 43
     window.ReactNativeWebView.postMessage(JSON.stringify({ width: Math.min(width, screen.width), height: height * usingScale }));
48 44
 
49 45
     // Make additional height checks (required to fix issues wit twitter embeds)
@@ -83,7 +79,7 @@ const detectZoomChanged = `
83 79
   var lastScale = 1.0;
84 80
   var doubleTapDelay = 400;
85 81
   function detectZoomChanged() {
86
-    var tempZoomedin = (screen.width / window.innerWidth) > (usingScale || 1);
82
+    var tempZoomedin = (screen.width / window.innerWidth) > usingScale;
87 83
     tempZoomedin !== zoomedin && window.ReactNativeWebView.postMessage(JSON.stringify({ zoomedin: tempZoomedin }));
88 84
     zoomedin = tempZoomedin;
89 85
   }
@@ -242,4 +238,4 @@ export const shouldUpdate = ({ prevProps, nextProps }) => {
242 238
     }
243 239
   }
244 240
   return false;
245
-};
241
+};

+ 2
- 2
demo/ios/Podfile.lock Zobrazit soubor

@@ -236,7 +236,7 @@ PODS:
236 236
     - React-cxxreact (= 0.63.0)
237 237
     - React-jsi (= 0.63.0)
238 238
   - React-jsinspector (0.63.0)
239
-  - react-native-webview (10.3.2):
239
+  - react-native-webview (10.7.0):
240 240
     - React
241 241
   - React-RCTActionSheet (0.63.0):
242 242
     - React-Core/RCTActionSheetHeaders (= 0.63.0)
@@ -450,7 +450,7 @@ SPEC CHECKSUMS:
450 450
   React-jsi: 254710f3a97e587427bfbf3011dacec2af66a1fc
451 451
   React-jsiexecutor: 0e0cb4e170ca72d4bb1179843d08dcbea3d100ac
452 452
   React-jsinspector: fc661eff8edbfb7e22119382c13f33bcadde0f3c
453
-  react-native-webview: 679b6f400176e2ea8a785acf7ae16cf282e7d1eb
453
+  react-native-webview: 6edf4d6f71b9161fc3e96083726a538ee395304d
454 454
   React-RCTActionSheet: aadd91a1d6cbfae50dd41f140004f816e9e47ade
455 455
   React-RCTAnimation: 7fa2ef6c0ef1e3f0b7d2261c827ec94412deb5e6
456 456
   React-RCTBlob: ccbbc70295aee3a76a70323b48f63fb7a7fcffd6

+ 1
- 1
demo/package.json Zobrazit soubor

@@ -13,7 +13,7 @@
13 13
     "react": "16.13.1",
14 14
     "react-native": "0.63.0",
15 15
     "react-native-autoheight-webview": "../",
16
-    "react-native-webview": "^10.3.2"
16
+    "react-native-webview": "^10.7.0"
17 17
   },
18 18
   "devDependencies": {
19 19
     "@babel/core": "^7.8.4",

+ 5
- 5
demo/yarn.lock Zobrazit soubor

@@ -5432,14 +5432,14 @@ react-is@^16.12.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6:
5432 5432
   integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
5433 5433
 
5434 5434
 react-native-autoheight-webview@../:
5435
-  version "1.5.1"
5435
+  version "1.5.2"
5436 5436
   dependencies:
5437 5437
     prop-types "^15.7.2"
5438 5438
 
5439
-react-native-webview@^10.3.2:
5440
-  version "10.3.2"
5441
-  resolved "https://registry.yarnpkg.com/react-native-webview/-/react-native-webview-10.3.2.tgz#c634946152099c95d521a3abc71065d1d642e192"
5442
-  integrity sha512-4A8FKL/puonkqQ1FOKd+iPulqRXCG4inmIK4pQ60zv9Ua+YkBKLxxofQiCvRwIXSSgAXYT+AE3rOHr3bx4A/cw==
5439
+react-native-webview@^10.7.0:
5440
+  version "10.7.0"
5441
+  resolved "https://registry.yarnpkg.com/react-native-webview/-/react-native-webview-10.7.0.tgz#b96e152ffdae4eeffaa74f43671a35733885b52d"
5442
+  integrity sha512-4TSYwJqMBUTKB9+xqGbPwx+eLXbp6RRD7lQ2BumT8eSTfuuqr2rXNqcrlKU1VRla7QGGYowmYmxl2aXIx5k9wA==
5443 5443
   dependencies:
5444 5444
     escape-string-regexp "2.0.0"
5445 5445
     invariant "2.2.4"