From f37ad91f854c460b700f24185cdf400abda18b99 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 26 Jun 2020 22:25:18 +0100 Subject: [PATCH] queue dragging --- templates/script.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/templates/script.js b/templates/script.js index 6f0f123e..96293241 100644 --- a/templates/script.js +++ b/templates/script.js @@ -5,6 +5,7 @@ general_timeout = 10000; messages = Object(); var our_dnd_type = "text/puvnex-game-server-dummy"; +drag_posting = false; function xhr_post_then(url,data,good) { var xhr = new XMLHttpRequest(); @@ -69,11 +70,28 @@ function drag_mousemove(e) { delt.setAttributeNS(null, "x", x); delt.setAttributeNS(null, "y", y); console.log(delt); + var l = [Math.round(x),Math.round(y)]; + if (!drag_posting) { + drag_posting = l; + drag_posted(); + } else { + drag_posting = l; + } + } +} + +function drag_posted() { + if (!dragging) { + drag_posting = false; + } else if (drag_posting == true) { + drag_posting = false; + } else { xhr_post_then('/_/api/m',JSON.stringify({ t : token, p : delt.dataset.p, - l : [Math.round(x),Math.round(y)], - }), function(){}); + l : drag_posting, + }), drag_posted); + drag_posting = true; } } -- 2.30.2