|
@@ -31,6 +31,7 @@ export default class AutoHeightWebView extends Component {
|
31
|
31
|
}
|
32
|
32
|
|
33
|
33
|
componentDidMount() {
|
|
34
|
+ this.stopInterval = false;
|
34
|
35
|
this.intervalPostMessage();
|
35
|
36
|
}
|
36
|
37
|
|
|
@@ -57,6 +58,7 @@ export default class AutoHeightWebView extends Component {
|
57
|
58
|
componentDidUpdate(prevProps, prevState) {
|
58
|
59
|
if (this.htmlHasChanged) {
|
59
|
60
|
if (this.state.isOnLoadingStart && this.state.height === 0 && this.state.heightOffset === 0) {
|
|
61
|
+ this.stopInterval = false;
|
60
|
62
|
this.intervalPostMessage();
|
61
|
63
|
this.htmlHasChanged = false;
|
62
|
64
|
this.setState({ isOnLoadingStart: false });
|
|
@@ -84,14 +86,16 @@ export default class AutoHeightWebView extends Component {
|
84
|
86
|
|
85
|
87
|
intervalPostMessage() {
|
86
|
88
|
this.interval = setInterval(() => {
|
87
|
|
- this.postMessage('getBodyHeight');
|
|
89
|
+ if (!this.stopInterval) {
|
|
90
|
+ this.postMessage('getBodyHeight');
|
|
91
|
+ }
|
88
|
92
|
}, 205);
|
89
|
93
|
}
|
90
|
94
|
|
91
|
95
|
onMessage(e) {
|
92
|
96
|
const height = parseInt(e.nativeEvent.data);
|
93
|
|
- console.log(height);
|
94
|
97
|
if (height) {
|
|
98
|
+ this.stopInterval = true;
|
95
|
99
|
clearInterval(this.interval);
|
96
|
100
|
this.setState({
|
97
|
101
|
heightOffset: this.props.heightOffset,
|