X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Ftracker%2FCanvas.js;h=89339abb346eedcebbb870d7e3044bac2705bf29;hb=fee2a910a23392383d7178e3fcb137c13fbc7add;hp=1258776809c000152abb72187398cf62e46f6b3b;hpb=7414634d59c94fc5fa2cf9c080324e6c901fa1c9;p=alttp.git diff --git a/resources/js/components/tracker/Canvas.js b/resources/js/components/tracker/Canvas.js index 1258776..89339ab 100644 --- a/resources/js/components/tracker/Canvas.js +++ b/resources/js/components/tracker/Canvas.js @@ -67,22 +67,21 @@ const Canvas = () => { const bbox = canvas.select('.background'); const start = { x: 0, y: 0 }; const onStart = function (e) { - const bounds = bbox.node().getBoundingClientRect(); start.x = e.x; start.y = e.y; - setDragging({ - icon: this.dataset['icon'], - x: (e.x - bounds.x) / bounds.width, - y: (e.y - bounds.y) / bounds.height, - }); }; const onDrag = function (e) { const bounds = bbox.node().getBoundingClientRect(); - setDragging({ - icon: this.dataset['icon'], - x: (e.x - bounds.x) / bounds.width, - y: (e.y - bounds.y) / bounds.height, - }); + const distance = Math.max(Math.abs(e.x - start.x), Math.abs(e.y - start.y)); + if (distance > 5) { + setDragging({ + icon: this.dataset['icon'], + x: (e.x - bounds.x) / bounds.width, + y: (e.y - bounds.y) / bounds.height, + }); + } else { + setDragging(null); + } }; const onEnd = function (e) { const bounds = bbox.node().getBoundingClientRect();