From 1d3ee8781752f0eab80d59be4ad447df0d37a8b0 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 7 Jun 2020 21:52:06 +0100 Subject: [PATCH] wip non dnd, wip refactor for movement --- templates/script.js | 8 ++++---- templates/test.html | 29 +++++++++++++++++------------ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/templates/script.js b/templates/script.js index 82036065..607c8834 100644 --- a/templates/script.js +++ b/templates/script.js @@ -17,8 +17,8 @@ function drag_mousedown(e) { dcx = e.clientX; dcy = e.clientY; delt = e.target; - dox = parseFloat(delt.getAttributeNS(null,"cx")); - doy = parseFloat(delt.getAttributeNS(null,"cy")); + dox = parseFloat(delt.getAttributeNS(null,"x")); + doy = parseFloat(delt.getAttributeNS(null,"y")); dragging = false; window.addEventListener('mousemove', drag_mousemove, true); window.addEventListener('mouseup', drag_mouseup, true); @@ -39,8 +39,8 @@ function drag_mousemove(e) { if (dragging) { var x = dox + ddx; var y = doy + ddy; - delt.setAttributeNS(null, "cx", x); - delt.setAttributeNS(null, "cy", y); + delt.setAttributeNS(null, "x", x); + delt.setAttributeNS(null, "y", y); console.log(delt); } } diff --git a/templates/test.html b/templates/test.html index 923d38a9..c16a284f 100644 --- a/templates/test.html +++ b/templates/test.html @@ -2,19 +2,24 @@ T -
nothing
-

- +

+

nothing
+

+ - + + + + - + -- 2.30.2