ソースを参照

update android version; update version to 0.0.13

iou90 7 年 前
コミット
711d824539
共有2 個のファイルを変更した12 個の追加8 個の削除を含む
  1. 11
    7
      autoHeightWebView/index.android.js
  2. 1
    1
      package.json

+ 11
- 7
autoHeightWebView/index.android.js ファイルの表示

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

+ 1
- 1
package.json ファイルの表示

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