MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
no edit summary
OtherXAdmin (talk | contribs) No edit summary |
OtherXAdmin (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
/* Restrict zooming out beyond the initial page size on mobile */ | /* Restrict zooming out beyond the initial page size on mobile */ | ||
var initialScale = 1; | var initialScale = 1; | ||
var pinchStartDistance; | |||
document.addEventListener(' | document.addEventListener('gesturestart', function(e) { | ||
pinchStartDistance = getPinchDistance(e); | |||
}); | |||
document.addEventListener('gesturechange', function(e) { | |||
var pinchDistance = getPinchDistance(e); | |||
if (pinchDistance > pinchStartDistance) { | |||
/* Zoom in */ | /* Zoom in */ | ||
initialScale *= 1.1; | initialScale *= 1.1; | ||
} else if ( | } else if (pinchDistance < pinchStartDistance && initialScale > 1) { | ||
/* Zoom out */ | /* Zoom out */ | ||
initialScale /= 1.1; | initialScale /= 1.1; | ||
Line 13: | Line 20: | ||
updateViewport(); | updateViewport(); | ||
}); | }); | ||
function getPinchDistance(e) { | |||
return Math.hypot(e.touches[0].clientX - e.touches[1].clientX, e.touches[0].clientY - e.touches[1].clientY); | |||
} | |||
function updateViewport() { | function updateViewport() { |