From a64c2a665af1abe0b91f1c5eb1f97df91ed8a4de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 3 Oct 2021 17:48:13 +0200 Subject: Further work, rework popup. --- static/dragable.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'static/dragable.js') diff --git a/static/dragable.js b/static/dragable.js index 41895760..6eb0b999 100644 --- a/static/dragable.js +++ b/static/dragable.js @@ -21,14 +21,16 @@ function bind_popup_control (nav) { nav.style.cursor = "grabbing"; nav.dataset.grabbed = "true"; nav.dataset.grabPoint = e.clientX + ";" + e.clientY; - let popup = nav.closest(".popup-container"); + // let popup = nav.closest(".popup-container"); + let popup = nav.closest("popup-element"); nav.dataset.startPoint = popup.offsetLeft + ";" + popup.offsetTop; } 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"); + // let popup = nav.closest(".popup-container"); + let popup = nav.closest("popup-element"); popup.style.left = startX + (e.clientX - x) + "px"; popup.style.top = startY + (e.clientY - y) + "px"; -- cgit v1.2.3 From c6c65f9e8273a5bc1b2ac1155d66003d2b98591c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 4 Oct 2021 17:40:59 +0200 Subject: {.js => .ts} on relavant files. --- static/dragable.js | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 static/dragable.js (limited to 'static/dragable.js') diff --git a/static/dragable.js b/static/dragable.js deleted file mode 100644 index 6eb0b999..00000000 --- a/static/dragable.js +++ /dev/null @@ -1,43 +0,0 @@ -/* - Apply to a given component to make it draggable. - Drag area (usually a title bar) should be be the only argument. - It is REQUIRED that the object which should be moved have the class - 'popup-container'; -*/ - - -/* - Given the navbar of a popup, make it dragable. - */ -function bind_popup_control (nav) { - - if (! nav.closest('.popup-container')) { - throw TypeError('not a popup container'); - } - - nav.onmousedown = function (e) { - /* Ignore mousedown on children */ - if (e.target != nav) return; - nav.style.cursor = "grabbing"; - nav.dataset.grabbed = "true"; - nav.dataset.grabPoint = e.clientX + ";" + e.clientY; - // let popup = nav.closest(".popup-container"); - let popup = nav.closest("popup-element"); - nav.dataset.startPoint = popup.offsetLeft + ";" + popup.offsetTop; - } - 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"); - let popup = nav.closest("popup-element"); - - popup.style.left = startX + (e.clientX - x) + "px"; - popup.style.top = startY + (e.clientY - y) + "px"; - } - }); - window.addEventListener('mouseup', function () { - nav.dataset.grabbed = ""; - nav.style.cursor = ""; - }); -} -- cgit v1.2.3