disableZooming function
void
disableZooming()
Disables browser zooming.
Implementation
void disableZooming() {
if (_disableZooming) return;
_disableZooming = true;
var scriptCode = '''
if ( window.UIConsole == null ) {
UIConsole = function(o) {
console.log(o);
}
}
var _blockZoom_lastTime = new Date() ;
var blockZoom = function(event) {
var s = event.scale ;
if (s > 1 || s < 1) {
var now = new Date() ;
var elapsedTime = now.getTime() - _blockZoom_lastTime.getTime() ;
if (elapsedTime > 1000) {
UIConsole('Block event['+ event.type +'].scale:'+ s) ;
}
_blockZoom_lastTime = now ;
event.preventDefault();
}
}
var block = function(types) {
UIConsole('Block scale event of types: '+types) ;
for (var i = 0; i < types.length; i++) {
var t = types[i];
window.addEventListener(t, blockZoom, { passive: false } );
}
}
block( ["gesturestart", "gestureupdate", "gestureend", "touchenter", "touchstart", "touchmove", "touchend", "touchleave"]);
''';
addJavaScriptCode(scriptCode);
}