Browse Source

update android version; update version to 0.0.13

iou90 7 years ago
parent
commit
711d824539
2 changed files with 12 additions and 8 deletions
  1. 11
    7
      autoHeightWebView/index.android.js
  2. 1
    1
      package.json

+ 11
- 7
autoHeightWebView/index.android.js View File

@@ -31,8 +31,7 @@ export default class AutoHeightWebView extends Component {
31 31
     }
32 32
 
33 33
     componentDidMount() {
34
-        this.stopInterval = false;
35
-        this.intervalPostMessage();
34
+        this.startInterval();
36 35
     }
37 36
 
38 37
     componentWillReceiveProps(nextProps) {
@@ -59,7 +58,7 @@ export default class AutoHeightWebView extends Component {
59 58
         if (this.htmlHasChanged) {
60 59
             if (this.state.isOnLoadingStart && this.state.height === 0 && this.state.heightOffset === 0) {
61 60
                 this.stopInterval = false;
62
-                this.intervalPostMessage();
61
+                this.startInterval();
63 62
                 this.htmlHasChanged = false;
64 63
                 this.setState({ isOnLoadingStart: false });
65 64
             }
@@ -67,7 +66,7 @@ export default class AutoHeightWebView extends Component {
67 66
     }
68 67
 
69 68
     componentWillUnmount() {
70
-        clearInterval(this.interval);
69
+        this.stopInterval();
71 70
     }
72 71
 
73 72
     onLoadingStart() {
@@ -84,7 +83,8 @@ export default class AutoHeightWebView extends Component {
84 83
         );
85 84
     };
86 85
 
87
-    intervalPostMessage() {
86
+    startInterval() {
87
+        this.stopInterval = false;
88 88
         this.interval = setInterval(() => {
89 89
             if (!this.stopInterval) {
90 90
                 this.postMessage('getBodyHeight');
@@ -92,11 +92,15 @@ export default class AutoHeightWebView extends Component {
92 92
         }, 205);
93 93
     }
94 94
 
95
+    stopInterval() {
96
+        this.stopInterval = true;
97
+        clearInterval(this.interval);
98
+    }
99
+
95 100
     onMessage(e) {
96 101
         const height = parseInt(e.nativeEvent.data);
97 102
         if (height) {
98
-            this.stopInterval = true;
99
-            clearInterval(this.interval);
103
+            this.stopInterval();
100 104
             this.setState({
101 105
                 heightOffset: this.props.heightOffset,
102 106
                 height

+ 1
- 1
package.json View File

@@ -1,6 +1,6 @@
1 1
 {
2 2
   "name": "react-native-autoheightwebview",
3
-  "version": "0.0.12",
3
+  "version": "0.0.13",
4 4
   "description": "An auto height webview for React Native",
5 5
   "main": "autoHeightWebView",
6 6
   "files": ["android/", "autoHeightWebView/"],