chiark / gitweb /
wip non dnd, circle moves properly
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 7 Jun 2020 20:35:22 +0000 (21:35 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 7 Jun 2020 20:35:22 +0000 (21:35 +0100)
templates/script.js
templates/test.html

index 18becadfbd205e1346d1fb98c3fe0a9da84f5b07..8203606506f26834b034d1024486277256f48944 100644 (file)
@@ -2,12 +2,13 @@
 
 // xxx deployment note: need a whole bunch of domains for SSE conn limit
 
-status_node = document.getElementById('spong');
+status_node = document.getElementById('status');
 status_node.innerHTML = 'js-done'
 
 var our_dnd_type = "text/puvnex-game-server-dummy";
 
 dragthresh = 5;
+space = document.getElementById('space');
 
   console.log('foo1');
 
@@ -24,8 +25,9 @@ function drag_mousedown(e) {
 }
 
 function drag_mousemove(e) {
-  ddx = e.clientX - dcx;
-  ddy = e.clientY - dcy;
+  ctm = space.getScreenCTM();
+  ddx = (e.clientX - dcx)/ctm.a;
+  ddy = (e.clientY - dcy)/ctm.d;
   if (!dragging) {
     ddr2 = ddx*ddx + ddy*ddy;
     if (ddr2 > dragthresh) {
index dddb28f2d5ec043fb29d00723d9ae516c0c23239..923d38a9b061f57bfb39228f9f13e670ea9e5a66 100644 (file)
@@ -2,9 +2,10 @@
     <title>T</title>
   </head>
   <body>
-<div id="spong">nothing</div>
+<div id="status">nothing</div>
 <p>
-  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 200"
+  <svg id="space"
+       xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 200"
        ondragstart="test_dragstart(event)"
        >
       <rect fill="green" x="42" y="56" width="100" height="80"/>