Center canvas with an extended margin: auto trick. Gets rid of half-pixel positions possible with translate().

This commit is contained in:
Simo Kinnunen
2014-09-12 22:50:34 +09:00
parent 5ade5fd61c
commit c6f63be01c
3 changed files with 20 additions and 11 deletions

View File

@@ -27,21 +27,29 @@ device-screen {
user-select: none;
}
device-screen .screen-touch {
width: 100%;
height: 100%;
device-screen .screen-center {
position: absolute;
top: -100%;
right: -100%;
bottom: -100%;
left: -100%;
pointer-events: none;
}
device-screen canvas {
position: absolute;
top: 50%;
left: 50%;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
pointer-events: none; /* MUST HAVE or touch coordinates will be off */
transition: width 100ms linear, -webkit-transform 250ms ease-in-out;
-webkit-transform-origin: 50% 50%;
transform-origin: 50% 50%;
-webkit-transform: rotate(0deg);
transform: translate(-50%, -50%) rotate(0deg);
transform: rotate(0deg);
}
device-screen .finger {