|
@@ -8,6 +8,7 @@ import React, {
|
8
|
8
|
import {
|
9
|
9
|
Animated,
|
10
|
10
|
Dimensions,
|
|
11
|
+ StyleSheet,
|
11
|
12
|
View,
|
12
|
13
|
WebView
|
13
|
14
|
} from 'react-native';
|
|
@@ -84,17 +85,12 @@ export default class AutoHeightWebView extends ImmutableComponent {
|
84
|
85
|
const { enableAnimation, source, heightOffset, customScript, style } = this.props;
|
85
|
86
|
const webViewSource = Object.assign({}, source, { baseUrl: 'web/' });
|
86
|
87
|
return (
|
87
|
|
- <Animated.View style={[{
|
|
88
|
+ <Animated.View style={[Styles.container, {
|
88
|
89
|
opacity: enableAnimation ? this.opacityAnimatedValue : 1,
|
89
|
|
- width: ScreenWidth,
|
90
|
90
|
height: height + heightOffset,
|
91
|
|
- backgroundColor: 'transparent'
|
92
|
91
|
}, style]}>
|
93
|
92
|
<WebView
|
94
|
|
- style={{
|
95
|
|
- flex: 1,
|
96
|
|
- backgroundColor: 'transparent'
|
97
|
|
- }}
|
|
93
|
+ style={Styles.webView}
|
98
|
94
|
injectedJavaScript={script + customScript}
|
99
|
95
|
scrollEnabled={false}
|
100
|
96
|
source={webViewSource}
|
|
@@ -130,6 +126,17 @@ AutoHeightWebView.defaultProps = {
|
130
|
126
|
|
131
|
127
|
const ScreenWidth = Dimensions.get('window').width;
|
132
|
128
|
|
|
129
|
+const Styles = StyleSheet.create({
|
|
130
|
+ container: {
|
|
131
|
+ width: ScreenWidth,
|
|
132
|
+ backgroundColor: 'transparent'
|
|
133
|
+ },
|
|
134
|
+ webView: {
|
|
135
|
+ flex: 1,
|
|
136
|
+ backgroundColor: 'transparent'
|
|
137
|
+ }
|
|
138
|
+});
|
|
139
|
+
|
133
|
140
|
// note that it can not get height when there are only text objects in a html body which does not make any sense
|
134
|
141
|
const BaseScript =
|
135
|
142
|
`
|