Constructor
new ve.init.mw.ViewportZoomHandler()
#
Prevent iOS browsers from wrongly zooming in the page when the surface is focussed. (T216446)
When the user places a cursor for text input anywhere on the page, iOS browsers zoom in the page to ensure the text size is legible and the cursor can be comfortably placed in the right place with a finger.
There's a browser bug that, on some devices (e.g. iPhone XS, but not iPhone SE), causes this zoom to occur even though our text is already using the required minimum font size (16px). Additionally, the zoom occurs when placing the cursor in image captions, which intentionally use a smaller font size.
In both cases the zoom is more problematic than helpful, because it causes parts of the toolbar to disappear outside the viewport.
To prevent it, temporarily add a tag like <meta name="viewport" content="maximum-scale=1.0">
to the page when the user is about to focus the editing surface. However, on iOS Chrome, this
also prevents intentional pinch-zoom. To avoid this, immediately remove the tag again after
focussing, or if it looks like the user is trying to zoom (used multi-touch or caused a scroll).
Methods
allowZoom()
#
Change the <meta name="viewport">
tag to allow automatic zooming once again.
<meta name="viewport">
tag to allow automatic zooming once again.
attach(surface)
#
Start listening to events and preventing zooming.
Parameters:
Name | Type | Description |
---|---|---|
surface |
ve.ui.Surface |
detach()
#
Stop listening to events.
onFocus()
#
Handle surface model focus events.
onTouchEnd(e)
#
onTouchMove(e)
#
onTouchStart(e)
#
preventZoom()
#
Change the <meta name="viewport">
tag to prevent automatic zooming.
<meta name="viewport">
tag to prevent automatic zooming.