aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-07-13 00:51:36 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-07-13 00:52:29 +0200
commit235316966e40ce2b28d94557a280f1bc3b9c2eef (patch)
treeae666a176f23b90374a3a6f8b8620df1c3475284
parentFix Javascript part of event removal. (diff)
downloadcalp-235316966e40ce2b28d94557a280f1bc3b9c2eef.tar.gz
calp-235316966e40ce2b28d94557a280f1bc3b9c2eef.tar.xz
Add basic movement of popups.
-rw-r--r--static/script.js22
-rw-r--r--static/style.css5
2 files changed, 27 insertions, 0 deletions
diff --git a/static/script.js b/static/script.js
index 008cc1e2..af0fba8f 100644
--- a/static/script.js
+++ b/static/script.js
@@ -324,6 +324,28 @@ window.onload = function () {
}
}
+ for (let nav of document.getElementsByClassName("popup-control")) {
+ nav.onmousedown = function (e) {
+ if (e.target != nav) return;
+ nav.style.cursor = "grabbing";
+ nav.dataset.grabbed = "true";
+ nav.dataset.grabPoint = e.layerX + ";" + e.layerY;
+ }
+ nav.onmousemove = function (e) {
+ if (nav.dataset.grabbed) {
+ let [x, y] = nav.dataset.grabPoint.split(";").map(Number);
+ let popup = nav.closest(".popup-container");
+
+ popup.style.left = popup.offsetLeft + (e.layerX - x) + "px";
+ popup.style.top = popup.offsetTop + (e.layerY - y) + "px";
+ }
+ }
+ nav.onmouseup = function () {
+ nav.dataset.grabbed = "";
+ nav.style.cursor = "";
+ }
+ }
+
for (let el of document.getElementsByClassName("event")) {
/* Popup script replaces need for anchors to events.
On mobile they also have the problem that they make
diff --git a/static/style.css b/static/style.css
index 88342c75..abb4f8c7 100644
--- a/static/style.css
+++ b/static/style.css
@@ -644,6 +644,9 @@ along with their colors.
display: none;
position: absolute;
z-index: 10;
+
+ left: 10px;
+ top: -50px;
}
.popup-container.visible {
@@ -680,6 +683,8 @@ along with their colors.
/* not needed, but the icons aren't text
and should therefor not be copied */
user-select: none;
+
+ cursor: grab;
}
.popup-control .btn {