|
@@ -87,7 +87,7 @@ export default class AutoHeightWebView extends PureComponent {
|
87
|
87
|
|
88
|
88
|
handleNavigationStateChange(navState) {
|
89
|
89
|
const height = Number(navState.title);
|
90
|
|
- if (height) {
|
|
90
|
+ if (height && height !== this.state.height) {
|
91
|
91
|
if (this.props.enableAnimation) {
|
92
|
92
|
this.opacityAnimatedValue.setValue(0);
|
93
|
93
|
}
|
|
@@ -139,14 +139,24 @@ const Styles = StyleSheet.create({
|
139
|
139
|
}
|
140
|
140
|
});
|
141
|
141
|
|
142
|
|
-// note that it can not get height when there are only text objects in a html body which does not make any sense
|
143
|
142
|
const BaseScript =
|
144
|
143
|
`
|
145
|
|
- ; (function () {
|
|
144
|
+ ;
|
|
145
|
+ (function () {
|
146
|
146
|
var i = 0;
|
|
147
|
+ var height = 0;
|
|
148
|
+ var wrapper = document.createElement('div');
|
|
149
|
+ wrapper.id = 'height-wrapper';
|
|
150
|
+ while (document.body.firstChild) {
|
|
151
|
+ wrapper.appendChild(document.body.firstChild);
|
|
152
|
+ }
|
|
153
|
+ document.body.appendChild(wrapper);
|
147
|
154
|
function updateHeight() {
|
148
|
|
- document.title = document.body.offsetHeight;
|
149
|
|
- window.location.hash = ++i;
|
|
155
|
+ if(document.body.offsetHeight !== height) {
|
|
156
|
+ height = wrapper.clientHeight;
|
|
157
|
+ document.title = wrapper.clientHeight;
|
|
158
|
+ window.location.hash = ++i;
|
|
159
|
+ }
|
150
|
160
|
}
|
151
|
161
|
updateHeight();
|
152
|
162
|
window.addEventListener('load', updateHeight);
|