Skip to content

Commit

Permalink
Hacks to improve user experience when changing orientation on phones
Browse files Browse the repository at this point in the history
I now think that much of our media queries with (max-device-height:
767px) actually should use (max-device-width: 767px) if the intent is
that they detect the case of mobile phones, as opposed to tablets.

Many mobile phones have a screen.height (which is what
max-device-height in CSS refers to) that is clearly larger than 767.
But a screen.width of 768 is what at least my 9.7 iPad has.

Change-Id: I3b44e32ec583837897b4aa390fc0ab92be59d163
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90752
Tested-by: Andras Timar <andras.timar@collabora.com>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
  • Loading branch information
Tor Lillqvist authored and timar committed Mar 19, 2020
1 parent a394b56 commit b62dcc0
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 28 deletions.
26 changes: 21 additions & 5 deletions loleaflet/css/loleaflet.css
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,28 @@ body {
width: 0;
}

/* Hide hamburger except on mobile phones */
#toolbar-hamburger {
width: 0;
}
@media (max-device-width: 767px) {
#toolbar-hamburger {
width: 36px;
}
/* In Safari on iPhone, the address bar is auto-hidden in landscape
* orientation. For some reason this prevents jQuery from
* getting events when tapping on the things in the toolbar at
* the top, like the hamburger button. To work around this,
* add a bit of padding to the body element. This is of course
* an extremely silly waste of precious vertical space and
* some other solution should be found.
*/
@media (orientation: landscape) {
body {
padding-top: 20px;
}
}
}

#mobile-edit-button {
position: absolute;
Expand Down Expand Up @@ -284,9 +303,6 @@ body {
bottom: 35px !important;
}

#toolbar-hamburger {
width: 36px;
}
#closebuttonwrapper {
display: none;
}
Expand All @@ -296,7 +312,7 @@ body {
}
}

@media (max-width: 767px) and (orientation: portrait), (max-device-height: 767px) and (orientation: portrait) {
@media (max-width: 767px) and (orientation: portrait) {
#presentation-controls-wrapper {
top: initial;
left: initial;
Expand Down Expand Up @@ -327,7 +343,7 @@ body {
bottom: 33px;
}
}
@media (max-width: 767px) and (orientation: landscape), (max-device-height: 767px) and (orientation: landscape) {
@media (max-width: 1023px) and (orientation: landscape) {
#presentation-controls-wrapper {
top: 41px;
bottom: 33px;
Expand Down
2 changes: 1 addition & 1 deletion loleaflet/css/menubar-mobile.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@media (max-width: 767px), (max-device-height: 767px) {
@media (max-device-width: 767px) {
.logo {
background-size: 100px;
max-width: 24px;
Expand Down
14 changes: 2 additions & 12 deletions loleaflet/css/menubar.css
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,11 @@
overflow: hidden;
}

/* Mobile menu toggle button */
/* Hamburger button */

.main-menu-btn {
margin: 2px 10px;
position: relative;
display: none;
width: 17px;
height: 21px;
text-indent: 17px;
Expand All @@ -167,7 +166,7 @@
}


/* hamburger icon */
/* Hamburger icon */

.main-menu-btn-icon,
.main-menu-btn-icon:before,
Expand Down Expand Up @@ -270,15 +269,6 @@
display: none;
}

/* hide the menu in mobile view */
#main-menu-state:not(:checked) ~ #main-menu {
display: none;
}

.main-menu-btn {
display: inline-block;
}

.main-nav {
position: absolute;
height: 0;
Expand Down
2 changes: 1 addition & 1 deletion loleaflet/css/mobilewizard.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@media (max-width: 767px), (max-device-height: 767px) {
@media (max-device-width: 767px) {
.menuwizard .menu-entry-icon{
padding-left: 4%;
}
Expand Down
2 changes: 1 addition & 1 deletion loleaflet/src/control/Control.Menubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ L.Control.Menubar = L.Control.extend({

$('#main-menu').bind('keydown', {self: this}, this._onKeyDown);

if (L.Browser.mobile)
if (window.mode.isMobile())
$('#main-menu').parent().css('height', '0');

var self = this;
Expand Down
17 changes: 9 additions & 8 deletions loleaflet/src/map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,20 @@ L.Map = L.Evented.extend({

// We need core's knowledge of whether it is a mobile phone or not (which is
// what .uno:LOKSetMobile does) to be in sync with the test in
// _onJSDialogMsg in TileLayer.js but we don't have the clout to do so
// except for the iOS app out of fear of breaking something.
if (L.Browser.mobile && (!window.ThisIsTheiOSApp || screen.width < 768))
// _onJSDialogMsg in TileLayer.js.
if (window.mode.isMobile())
{
this._size = new L.Point(0,0);
this._onResize();
this._socket.sendMessage('uno .uno:LOKSetMobile');
// Add a style sheet for mobile phones. Just a placeholder so far.
// Add a style sheet for mobile phones. Doing it here is hopefully more
// reliable that relying on CSS media queries looking at the window or device size.
var style = document.createElement('style');
style.innerHTML = ' \
#foobar { \
background: red; \
} \
style.innerHTML = ' \
/* Hide the menu bar in a horribly convoluted way */ \
#main-menu-state:not(:checked) ~ #main-menu { \
display: none; \
} \
';
document.head.appendChild(style);
}
Expand Down

0 comments on commit b62dcc0

Please sign in to comment.