From: Ian Jackson Date: Sun, 7 Jun 2020 20:52:06 +0000 (+0100) Subject: wip non dnd, wip refactor for movement X-Git-Tag: otter-0.2.0~1599 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=1d3ee8781752f0eab80d59be4ad447df0d37a8b0;p=otter.git wip non dnd, wip refactor for movement --- 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
+

+ - + + + + - +