Skip to content

Commit caefd87

Browse files
committed
mobile safe stacking
1 parent 0680a58 commit caefd87

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

browser/dasher/userinterface.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,31 @@ body {
294294
border-bottom: 1px solid #d8d9db;
295295
}
296296

297+
#user-interface.ui-mobile-stack .ui-main-area {
298+
grid-template-columns: 1fr;
299+
grid-template-rows: minmax(0, 1fr) 120px;
300+
}
301+
302+
#user-interface.ui-mobile-stack .ui-main-area.ui-message-position-right .ui-message-resizer,
303+
#user-interface.ui-mobile-stack .ui-main-area.ui-message-position-top .ui-message-resizer {
304+
display: none;
305+
}
306+
307+
#user-interface.ui-mobile-stack .ui-main-area.ui-message-position-right > svg,
308+
#user-interface.ui-mobile-stack .ui-main-area.ui-message-position-top > svg {
309+
grid-column: 1;
310+
grid-row: 1;
311+
}
312+
313+
#user-interface.ui-mobile-stack .ui-main-area.ui-message-position-right .ui-message-pane,
314+
#user-interface.ui-mobile-stack .ui-main-area.ui-message-position-top .ui-message-pane {
315+
grid-column: 1;
316+
grid-row: 2;
317+
border-left: none;
318+
border-top: 1px solid #d8d9db;
319+
padding: 6px;
320+
}
321+
297322
.ui-message-pane {
298323
min-width: 0;
299324
min-height: 0;

browser/dasher/userinterface.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export default class UserInterface {
167167
this._messagePosition = 'right';
168168
this._messagePaneWidth = 420;
169169
this._resizingMessagePane = false;
170+
this._mobileStackLayout = false;
170171
this._uiPreferencesKey = 'dasher-ui-preferences';
171172
this._gameMode = false;
172173
this._gameTarget = '';
@@ -893,6 +894,13 @@ export default class UserInterface {
893894
}
894895
}
895896

897+
_update_mobile_layout() {
898+
const width = this._parent.getBoundingClientRect().width;
899+
const forceStack = width <= 1100;
900+
this._mobileStackLayout = forceStack;
901+
this._parent.classList.toggle('ui-mobile-stack', forceStack);
902+
}
903+
896904
_attach_message_resizer() {
897905
if (this._messageResizeHandle === undefined || this._mainArea === undefined) {
898906
return;
@@ -1708,6 +1716,7 @@ export default class UserInterface {
17081716
}
17091717

17101718
_finish_load() {
1719+
this._update_mobile_layout();
17111720
this._limits.svgPiece = this._svg;
17121721
this._on_resize();
17131722
window.addEventListener('resize', this._on_resize.bind(this));
@@ -2017,6 +2026,7 @@ export default class UserInterface {
20172026
}
20182027

20192028
_on_resize() {
2029+
this._update_mobile_layout();
20202030
this.svgRect = this._svg.node.getBoundingClientRect();
20212031

20222032
if (this._controller !== null) {

0 commit comments

Comments
 (0)