Fix direction arrow hidden behind controller in portrait mode by offsetting for controller height
This commit is contained in:
1 parent
c4d83779df
commit
2d6b967a29
1 file changed
+10
-4
@@ -498,6 +498,12 @@ class Game {
|
|||||||
} else {
|
} else {
|
||||||
pd = dy >= 0 ? 'down' : 'up';
|
pd = dy >= 0 ? 'down' : 'up';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isLandscape = window.innerWidth > window.innerHeight;
|
||||||
|
const ctrlH = isLandscape ? 0 : Math.round(Math.min(148, Math.max(110, window.innerWidth * 0.22)));
|
||||||
|
const safeBottom = ctrlH + 12;
|
||||||
|
const midY = (viewH - ctrlH) / 2 - 16;
|
||||||
|
|
||||||
const glyphs = { right:'▶', left:'◀', up:'▲', down:'▼' };
|
const glyphs = { right:'▶', left:'◀', up:'▲', down:'▼' };
|
||||||
arrow.textContent = glyphs[pd];
|
arrow.textContent = glyphs[pd];
|
||||||
arrow.style.display = 'block';
|
arrow.style.display = 'block';
|
||||||
@@ -505,19 +511,19 @@ class Game {
|
|||||||
if (pd === 'right') {
|
if (pd === 'right') {
|
||||||
arrow.style.removeProperty('left');
|
arrow.style.removeProperty('left');
|
||||||
arrow.style.right = '12px';
|
arrow.style.right = '12px';
|
||||||
arrow.style.bottom = (viewH / 2 - 16) + 'px';
|
arrow.style.bottom = midY + 'px';
|
||||||
} else if (pd === 'left') {
|
} else if (pd === 'left') {
|
||||||
arrow.style.removeProperty('right');
|
arrow.style.removeProperty('right');
|
||||||
arrow.style.left = '12px';
|
arrow.style.left = '12px';
|
||||||
arrow.style.bottom = (viewH / 2 - 16) + 'px';
|
arrow.style.bottom = midY + 'px';
|
||||||
} else if (pd === 'up') {
|
} else if (pd === 'up') {
|
||||||
arrow.style.removeProperty('right');
|
arrow.style.removeProperty('right');
|
||||||
arrow.style.left = (viewW / 2 - 16) + 'px';
|
arrow.style.left = (viewW / 2 - 16) + 'px';
|
||||||
arrow.style.bottom = (viewH - 48) + 'px';
|
arrow.style.bottom = (viewH - ctrlH - 48) + 'px';
|
||||||
} else {
|
} else {
|
||||||
arrow.style.removeProperty('right');
|
arrow.style.removeProperty('right');
|
||||||
arrow.style.left = (viewW / 2 - 16) + 'px';
|
arrow.style.left = (viewW / 2 - 16) + 'px';
|
||||||
arrow.style.bottom = '12px';
|
arrow.style.bottom = safeBottom + 'px';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user