Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F29594248
T216446.html
matmarex (Bartosz Dziewoński)
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
matmarex
Jun 17 2019, 7:06 PM
2019-06-17 19:06:05 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
T216446.html
View Options
<
meta
id
=
"m"
name
=
"viewport"
content
=
"width=device-width"
>
<!-- <textarea id="a" style="width: 100%; height: 50%;">foo bar</textarea> -->
<
div
contenteditable
id
=
"a"
style
=
"font-size: 12px; width: 100%; height: 50%;"
>
foo bar
</
div
>
<
p
id
=
"zoom"
></
p
>
<
p
id
=
"log"
style
=
"white-space: pre"
></
p
>
<
script
>
function
log
(
text
)
{
document
.
getElementById
(
'log'
).
textContent
+=
'\n'
+
text
;
}
// Note that this doesn't actually prevent e.g. pinch-zoom on Safari, but it does prevent
// automatic zoom upon focussing an input with small font.
function
preventZoom
()
{
document
.
getElementById
(
'm'
).
setAttribute
(
'content'
,
"width=device-width, maximum-scale=1.0"
);
document
.
getElementById
(
'zoom'
).
textContent
=
'❌'
;
}
function
allowZoom
()
{
document
.
getElementById
(
'm'
).
setAttribute
(
'content'
,
"width=device-width"
);
document
.
getElementById
(
'zoom'
).
textContent
=
'✔'
;
}
allowZoom
();
var
wasMoved
=
false
;
document
.
getElementById
(
'a'
).
addEventListener
(
'touchstart'
,
function
(
e
)
{
log
(
'touchstart'
+
e
.
touches
.
length
);
if
(
e
.
touches
.
length
===
1
)
{
wasMoved
=
false
;
}
allowZoom
();
},
false
);
document
.
getElementById
(
'a'
).
addEventListener
(
'touchmove'
,
function
(
e
)
{
wasMoved
=
true
;
},
false
);
document
.
getElementById
(
'a'
).
addEventListener
(
'touchend'
,
function
(
e
)
{
log
(
'touchend'
+
e
.
touches
.
length
);
if
(
e
.
touches
.
length
===
0
&&
!
wasMoved
)
{
// There was a single touch point, that hasn't moved, and now it's gone.
// Looks like we're going to focus the input, so prevent automatic zoom.
preventZoom
();
}
else
{
// Otherwise, allow zoom, so that the user can pinch-zoom
allowZoom
();
}
},
false
);
document
.
getElementById
(
'a'
).
addEventListener
(
'focus'
,
function
(
e
)
{
log
(
'focus'
);
allowZoom
();
},
false
);
</
script
>
File Metadata
Details
Attached
Mime Type
text/html
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
7648785
Default Alt Text
T216446.html (1 KB)
Attached To
Mode
T216446: Page zooms slightly when focusing document on iPhone Chrome
Attached
Detach File
Event Timeline
Log In to Comment