summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2022-05-23 15:03:16 +0200
committerTor Andersson <tor@ccxvii.net>2022-05-23 15:46:50 +0200
commit64e341b777632e90e11f57b1be1782ab5178a074 (patch)
tree30c2c1be7edae27aca1c4f3607b4a7d97fab2690 /public
parentf693dbe9d98e3ae12264a7954391c255da9b8ab5 (diff)
downloadserver-64e341b777632e90e11f57b1be1782ab5178a074.tar.gz
Fix header to top of screen in mobile layout.
But allow the toolbar buttons to scroll offscreen.
Diffstat (limited to 'public')
-rw-r--r--public/common/play.css12
-rw-r--r--public/common/play.js18
2 files changed, 29 insertions, 1 deletions
diff --git a/public/common/play.css b/public/common/play.css
index 0b098af..314bf2a 100644
--- a/public/common/play.css
+++ b/public/common/play.css
@@ -372,7 +372,7 @@ header .replay button {
width: 100%;
height: auto;
grid-template-columns: 1fr;
- grid-template-rows: min-content;
+ grid-template-rows: 108px min-content;
overflow-x: clip;
overflow-y: auto;
}
@@ -380,8 +380,18 @@ header .replay button {
width: 100%;
background-color: rgba(255,255,255,0.9);
}
+ header.mobilefix {
+ position: fixed;
+ top: -40px;
+ }
header {
+ position: absolute;
+ min-height: 108px;
+ top: 0;
+ left: 0;
+ right: 0;
display: block;
+ z-index: 1000;
}
#prompt {
padding-left: 8px;
diff --git a/public/common/play.js b/public/common/play.js
index d8e4ee1..80ead70 100644
--- a/public/common/play.js
+++ b/public/common/play.js
@@ -585,6 +585,24 @@ function confirm_resign() {
send_message("resign");
}
+/* MOBILE PHONE LAYOUT */
+
+let mobile_scroll_header = document.querySelector("header");
+let mobile_scroll_last_y = 0;
+
+window.addEventListener("scroll", function scroll_mobile_fix (evt) {
+ if (mobile_scroll_header.clientWidth <= 640) {
+ if (window.scrollY > 40) {
+ if (mobile_scroll_last_y <= 40)
+ mobile_scroll_header.classList.add("mobilefix");
+ } else {
+ if (mobile_scroll_last_y > 40)
+ mobile_scroll_header.classList.remove("mobilefix");
+ }
+ mobile_scroll_last_y = window.scrollY;
+ }
+});
+
/* DEBUGGING */
function send_save() {