aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-07-13 01:12:32 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-07-13 01:12:32 +0200
commit72922d2644a8f8150d5e0453c646b473625208b7 (patch)
tree543d0aad15da81d1b7a937c762e2200a18c2b9b8
parentAdd basic movement of popups. (diff)
downloadcalp-72922d2644a8f8150d5e0453c646b473625208b7.tar.gz
calp-72922d2644a8f8150d5e0453c646b473625208b7.tar.xz
Fix popup movement.
-rw-r--r--static/script.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/static/script.js b/static/script.js
index af0fba8f..8a314bb9 100644
--- a/static/script.js
+++ b/static/script.js
@@ -329,21 +329,24 @@ window.onload = function () {
if (e.target != nav) return;
nav.style.cursor = "grabbing";
nav.dataset.grabbed = "true";
- nav.dataset.grabPoint = e.layerX + ";" + e.layerY;
+ nav.dataset.grabPoint = e.clientX + ";" + e.clientY;
+ let popup = nav.closest(".popup-container");
+ nav.dataset.startPoint = popup.offsetLeft + ";" + popup.offsetTop;
}
- nav.onmousemove = function (e) {
+ window.addEventListener('mousemove', function (e) {
if (nav.dataset.grabbed) {
let [x, y] = nav.dataset.grabPoint.split(";").map(Number);
+ let [startX, startY] = nav.dataset.startPoint.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";
+ popup.style.left = startX + (e.clientX - x) + "px";
+ popup.style.top = startY + (e.clientY - y) + "px";
}
- }
- nav.onmouseup = function () {
+ });
+ window.addEventListener('mouseup', function () {
nav.dataset.grabbed = "";
nav.style.cursor = "";
- }
+ });
}
for (let el of document.getElementsByClassName("event")) {