Selaa lähdekoodia

using function instead of arrow function for getInjectedSource to fix arrow function not supported problem below android 6.0, https://github.com/iou90/react-native-autoheight-webview/issues/139

iou90 4 vuotta sitten
vanhempi
commit
10bb38ea0a
1 muutettua tiedostoa jossa 4 lisäystä ja 2 poistoa
  1. 4
    2
      autoHeightWebView/utils.js

+ 4
- 2
autoHeightWebView/utils.js Näytä tiedosto

@@ -20,15 +20,17 @@ const updateSizeWithMessage = (element, scalesPageToFit) =>
20 20
   var maxHeightTheSameTimes = 5;
21 21
   var forceRefreshDelay = 1000;
22 22
   var forceRefreshTimeout;
23
+  var checkPostMessageTimeout;
23 24
 
24 25
   function updateSize(event) {
25 26
     if (
26 27
       !window.hasOwnProperty('ReactNativeWebView') || 
27 28
       !window.ReactNativeWebView.hasOwnProperty('postMessage')
28 29
     ) {
29
-      setTimeout(updateSize, 200);
30
+      checkPostMessageTimeout = setTimeout(updateSize, 200);
30 31
       return;
31 32
     }
33
+    clearTimeout(checkPostMessageTimeout);
32 34
     height = ${element}.offsetHeight || document.documentElement.offsetHeight;
33 35
     width = ${element}.offsetWidth || document.documentElement.offsetWidth;
34 36
     var needScale = width > screen.width;
@@ -121,7 +123,7 @@ const getInjectedSource = ({ html, script }) => `
121 123
 ${html}
122 124
 <script>
123 125
 // prevents code colissions with global scope
124
-(() => {
126
+(function() {
125 127
   ${script}
126 128
 })();
127 129
 </script>