Skip to content

Commit

Permalink
Merge pull request #194 from sents/dragmenu
Browse files Browse the repository at this point in the history
Make navigating overflowing menu more accessible
  • Loading branch information
lovasoa authored May 23, 2021
2 parents 729dbdb + e6e47eb commit 8e90aa3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
5 changes: 2 additions & 3 deletions client-data/board.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ html, body, svg {
transition-duration: 1s;
cursor: default;
padding: 10px;
pointer-events: none;
}

#menu.closed {
Expand Down Expand Up @@ -84,7 +83,7 @@ html, body, svg {
}

#settings {
margin-bottom: 0;
margin-bottom: 20px;
}

#menu .tool {
Expand Down Expand Up @@ -285,4 +284,4 @@ circle.opcursor {
label.tool-name[for=chooseColor] {
line-height: 10px;
}
}
}
2 changes: 1 addition & 1 deletion client-data/board.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<div id="loadingMessage">{{translations.loading}}</div>

<div id="menu" {{#hideMenu}}style="display:none;"{{/hideMenu}}>
<div id="menu" tabindex="0" {{#hideMenu}}style="display:none;"{{/hideMenu}}>
<div id="menuItems">
<ul id="tools" class="tools">
<li class="tool" tabindex="-1">
Expand Down
23 changes: 23 additions & 0 deletions client-data/js/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,3 +682,26 @@ Tools.svg.height.baseVal.value = document.body.clientHeight;
"stylesheet" : "style.css",
}
*/


(function () {
let pos = {top: 0, scroll:0};
let menu = document.getElementById("menu");
function menu_mousedown(evt) {
pos = {
top: menu.scrollTop,
scroll: evt.clientY
}
menu.addEventListener("mousemove", menu_mousemove);
document.addEventListener("mouseup", menu_mouseup);
}
function menu_mousemove(evt) {
const dy = evt.clientY - pos.scroll;
menu.scrollTop = pos.top - dy;
}
function menu_mouseup(evt) {
menu.removeEventListener("mousemove", menu_mousemove);
document.removeEventListener("mouseup", menu_mouseup);
}
menu.addEventListener("mousedown", menu_mousedown);
})()

0 comments on commit 8e90aa3

Please sign in to comment.