Browse Source

Merge branch 'master' into patch-1

iou90 4 years ago
parent
commit
ce39873f8c
No account linked to committer's email address
4 changed files with 12 additions and 16 deletions
  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 View File

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

+ 2
- 2
demo/ios/Podfile.lock View File

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

+ 1
- 1
demo/package.json View File

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

+ 5
- 5
demo/yarn.lock View File

5432
   integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
5432
   integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==
5433
 
5433
 
5434
 react-native-autoheight-webview@../:
5434
 react-native-autoheight-webview@../:
5435
-  version "1.5.1"
5435
+  version "1.5.2"
5436
   dependencies:
5436
   dependencies:
5437
     prop-types "^15.7.2"
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
   dependencies:
5443
   dependencies:
5444
     escape-string-regexp "2.0.0"
5444
     escape-string-regexp "2.0.0"
5445
     invariant "2.2.4"
5445
     invariant "2.2.4"