|
@@ -1,6 +1,6 @@
|
1
|
1
|
'use strict';
|
2
|
2
|
|
3
|
|
-import { Dimensions, Platform } from 'react-native';
|
|
3
|
+import { Dimensions } from 'react-native';
|
4
|
4
|
|
5
|
5
|
const domMutationObserveScript = `
|
6
|
6
|
var MutationObserver =
|
|
@@ -22,6 +22,9 @@ const updateSizeWithMessage = (element, scalesPageToFit) =>
|
22
|
22
|
var checkPostMessageTimeout;
|
23
|
23
|
|
24
|
24
|
function updateSize(event) {
|
|
25
|
+ if (zoomedin || scaling) {
|
|
26
|
+ return;
|
|
27
|
+ }
|
25
|
28
|
if (
|
26
|
29
|
!window.hasOwnProperty('ReactNativeWebView') ||
|
27
|
30
|
!window.ReactNativeWebView.hasOwnProperty('postMessage')
|
|
@@ -69,14 +72,23 @@ const setViewportContent = content => {
|
69
|
72
|
const detectZoomChanged = `
|
70
|
73
|
var zoomedin = false;
|
71
|
74
|
var latestTapStamp = 0;
|
72
|
|
- var lastScale = false;
|
|
75
|
+ var lastScale = 1.0;
|
|
76
|
+ var scaling = false;
|
73
|
77
|
var doubleTapDelay = 400;
|
74
|
78
|
function detectZoomChanged() {
|
75
|
79
|
var tempZoomedin = (screen.width / window.innerWidth) > 1;
|
76
|
80
|
tempZoomedin !== zoomedin && window.ReactNativeWebView.postMessage(JSON.stringify({ zoomedin: tempZoomedin }));
|
77
|
81
|
zoomedin = tempZoomedin;
|
78
|
82
|
}
|
|
83
|
+ window.addEventListener('ontouchstart', event => {
|
|
84
|
+ if (event.touches.length === 2) {
|
|
85
|
+ scaling = true;
|
|
86
|
+ }
|
|
87
|
+ })
|
79
|
88
|
window.addEventListener('touchend', event => {
|
|
89
|
+ if(scaling) {
|
|
90
|
+ scaleing = false;
|
|
91
|
+ }
|
80
|
92
|
var tempScale = event.scale;
|
81
|
93
|
tempScale !== lastScale && detectZoomChanged();
|
82
|
94
|
lastScale = tempScale;
|