commit 2a4d1c9fc294c4628b26f9d076f94d7f611e264b
parent 6a9de5b798ae168c5c88f984917ffc15fb7565ce
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Thu, 31 Oct 2024 11:53:07 -0700
Move furniture from where you press it
Before the furniture would always be centered on the pointer, now
it's much more natural in that it's position in relation to the
pointer is always the same.
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/files/floorplans/floorplan/main.js b/files/floorplans/floorplan/main.js
@@ -1165,7 +1165,7 @@ function furnitureHandler(ev, editor, state) {
// racy
if (state.move) {
let id = state.moving.attr("id")
- editor.mapFurniture({ x: state.move.x, y: state.move.y }, id)
+ editor.mapFurniture({ x: state.move.x + state.offset.x, y: state.move.y + state.offset.y }, id)
delete state.move
state.moved = true
}
@@ -1194,6 +1194,8 @@ function furnitureHandler(ev, editor, state) {
handled(ev)
state.moving = sel[0]
state.origin = press
+ let m = editor.backend.reqObj(lib.getID(sel[0]))
+ state.offset = { x: m.x - state.origin.x, y: m.y - state.origin.y }
return
}