|
@@ -74,14 +74,6 @@ export default class AutoHeightWebView extends ImmutableComponent {
|
74
|
74
|
this.setState({ script: currentScript });
|
75
|
75
|
}
|
76
|
76
|
|
77
|
|
- // componentDidUpdate(prevProps, prevState) {
|
78
|
|
- // // redisplay webview when changing source
|
79
|
|
- // if (this.state.isChangingSource) {
|
80
|
|
- // this.startInterval();
|
81
|
|
- // this.setState({ isChangingSource: false });
|
82
|
|
- // }
|
83
|
|
- // }
|
84
|
|
-
|
85
|
77
|
componentWillUnmount() {
|
86
|
78
|
this.stopInterval();
|
87
|
79
|
if (IsBelowKitKat) {
|
|
@@ -94,14 +86,6 @@ export default class AutoHeightWebView extends ImmutableComponent {
|
94
|
86
|
this.onMessage(body.message);
|
95
|
87
|
}
|
96
|
88
|
|
97
|
|
- postMessage(data) {
|
98
|
|
- UIManager.dispatchViewManagerCommand(
|
99
|
|
- findNodeHandle(this.webview),
|
100
|
|
- UIManager.RCTAutoHeightWebView.Commands.postMessage,
|
101
|
|
- [String(data)]
|
102
|
|
- );
|
103
|
|
- };
|
104
|
|
-
|
105
|
89
|
// below kitkat
|
106
|
90
|
sendToWebView(message) {
|
107
|
91
|
UIManager.dispatchViewManagerCommand(
|
|
@@ -111,6 +95,14 @@ export default class AutoHeightWebView extends ImmutableComponent {
|
111
|
95
|
);
|
112
|
96
|
}
|
113
|
97
|
|
|
98
|
+ postMessage(data) {
|
|
99
|
+ UIManager.dispatchViewManagerCommand(
|
|
100
|
+ findNodeHandle(this.webview),
|
|
101
|
+ UIManager.RCTAutoHeightWebView.Commands.postMessage,
|
|
102
|
+ [String(data)]
|
|
103
|
+ );
|
|
104
|
+ };
|
|
105
|
+
|
114
|
106
|
startInterval() {
|
115
|
107
|
this.finishInterval = false;
|
116
|
108
|
this.interval = setInterval(() => {
|
|
@@ -209,11 +201,13 @@ export default class AutoHeightWebView extends ImmutableComponent {
|
209
|
201
|
}
|
210
|
202
|
|
211
|
203
|
AutoHeightWebView.propTypes = {
|
212
|
|
- enableAnimation: PropTypes.bool,
|
213
|
204
|
source: WebView.propTypes.source,
|
214
|
205
|
onHeightUpdated: PropTypes.func,
|
215
|
206
|
customScript: PropTypes.string,
|
216
|
|
- // offset rn webview margin
|
|
207
|
+ enableAnimation: PropTypes.bool,
|
|
208
|
+ // only works on enable animation
|
|
209
|
+ animationDuration: PropTypes.number,
|
|
210
|
+ // offset of rn webview margin
|
217
|
211
|
heightOffset: PropTypes.number,
|
218
|
212
|
// baseUrl not work in android 4.3 or below version
|
219
|
213
|
enableBaseUrl: PropTypes.bool,
|
|
@@ -227,6 +221,7 @@ AutoHeightWebView.propTypes = {
|
227
|
221
|
}
|
228
|
222
|
|
229
|
223
|
AutoHeightWebView.defaultProps = {
|
|
224
|
+ enableAnimation: true,
|
230
|
225
|
animationDuration: 555,
|
231
|
226
|
enableBaseUrl: false,
|
232
|
227
|
heightOffset: 20
|