|
@@ -2,12 +2,14 @@
|
2
|
2
|
|
3
|
3
|
import React, { PureComponent } from 'react';
|
4
|
4
|
|
5
|
|
-import { Animated, StyleSheet, WebView } from 'react-native';
|
|
5
|
+import { Animated, StyleSheet } from 'react-native';
|
6
|
6
|
|
7
|
7
|
import PropTypes from 'prop-types';
|
8
|
8
|
|
9
|
9
|
import { commonPropTypes } from './propTypes.js';
|
10
|
10
|
|
|
11
|
+import { WebView } from 'react-native-webview';
|
|
12
|
+
|
11
|
13
|
import {
|
12
|
14
|
isEqual,
|
13
|
15
|
setState,
|
|
@@ -39,7 +41,6 @@ export default class AutoHeightWebView extends PureComponent {
|
39
|
41
|
|
40
|
42
|
static defaultProps = {
|
41
|
43
|
baseUrl: 'web/',
|
42
|
|
- scalesPageToFit: false,
|
43
|
44
|
enableAnimation: true,
|
44
|
45
|
animationDuration: 255,
|
45
|
46
|
heightOffset: 12
|
|
@@ -133,7 +134,6 @@ export default class AutoHeightWebView extends PureComponent {
|
133
|
134
|
onLoadStart,
|
134
|
135
|
onLoadEnd,
|
135
|
136
|
onShouldStartLoadWithRequest,
|
136
|
|
- scalesPageToFit,
|
137
|
137
|
enableAnimation,
|
138
|
138
|
heightOffset,
|
139
|
139
|
style,
|
|
@@ -169,7 +169,6 @@ export default class AutoHeightWebView extends PureComponent {
|
169
|
169
|
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
|
170
|
170
|
style={styles.webView}
|
171
|
171
|
scrollEnabled={!!scrollEnabled}
|
172
|
|
- scalesPageToFit={scalesPageToFit}
|
173
|
172
|
injectedJavaScript={script}
|
174
|
173
|
source={source}
|
175
|
174
|
onNavigationStateChange={this.handleNavigationStateChange}
|
|
@@ -184,12 +183,16 @@ const styles = StyleSheet.create({
|
184
|
183
|
backgroundColor: 'transparent'
|
185
|
184
|
},
|
186
|
185
|
webView: {
|
187
|
|
- flex: 1,
|
188
|
|
- backgroundColor: 'transparent'
|
|
186
|
+ backgroundColor: 'transparent',
|
|
187
|
+ flex: 1
|
189
|
188
|
}
|
190
|
189
|
});
|
191
|
190
|
|
|
191
|
+// add viewport setting to meta for WKWebView
|
192
|
192
|
const commonScript = `
|
|
193
|
+ var meta = document.createElement('meta');
|
|
194
|
+ meta.setAttribute('name', 'viewport');
|
|
195
|
+ meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);
|
193
|
196
|
updateSize();
|
194
|
197
|
window.addEventListener('load', updateSize);
|
195
|
198
|
window.addEventListener('resize', updateSize);
|