www.spaceplanner.app

Web client to the spaceplanner API
git clone git://jacobedwards.org/www.spaceplanner.app
Log | Files | Refs

commit bb36a6173a0205e6db8a2a1448aba61465ef7ea4
parent 5a15515e01664537615f594809fecab2d7827fb1
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date:   Mon, 23 Sep 2024 11:26:38 -0700

Improve behavior of precisePointHandler

Use the last mousedown to determine double click instead of mouseup
which causes clicking right after having drug a point to it's new
location to create a new point instead of moving it, which is the
behavior I'm looking for.

Diffstat:
Mfiles/floorplans/floorplan/main.js | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/files/floorplans/floorplan/main.js b/files/floorplans/floorplan/main.js @@ -429,7 +429,7 @@ function precisePointHandler(event, editor, state) { state.menu.remove() } for (let i in state) { - if (i !== "lastUp") { + if (i !== "lastLastDown") { delete state[i] } } @@ -548,8 +548,9 @@ function precisePointHandler(event, editor, state) { } let cursor = editor.draw.point(event.clientX, event.clientY).vec() - if (event.type === "mouseup") { - state.lastUp = Date.now() + state.lastDown = state.lastLastDown + if (event.type === "mousedown") { + state.lastLastDown = Date.now() } if (state.to == undefined) { @@ -563,7 +564,7 @@ function precisePointHandler(event, editor, state) { return } - if (state.lastUp != null && elapsed(state.lastUp) <= 500) { + if (state.lastDown != null && elapsed(state.lastDown) <= 500) { state.to = state.from state.from = null