commit 83b21cf8c2c527e807755e8968591a200bac9528
parent b8d0e7f186419b06334b1d5b3cf85c3aec921479
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Tue, 15 Oct 2024 20:18:30 -0700
Fix selection not accounting for transforms
Use rbox instead of bbox in the touching (used to determine selection
when nothing directly under pointer) method for SVG.Shapes and added
insideT[ransformed] method to be inside using rbox aswell.
Diffstat:
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/files/floorplans/floorplan/editor.js b/files/floorplans/floorplan/editor.js
@@ -596,7 +596,7 @@ export class FloorplanEditor {
let done = {}
let inside = []
for (let i = 0; i < children.length; ++i) {
- if (children[i][options.method ?? "inside"](point.x, point.y, options.minsize)) {
+ if (children[i][options.method ?? "insideT"](point.x, point.y, options.minsize)) {
if (inside.push(children[i]) >= options.max) {
return inside
}
diff --git a/files/floorplans/floorplan/geometry.js b/files/floorplans/floorplan/geometry.js
@@ -22,8 +22,16 @@ SVG.extend(SVG.Shape, {
return this.bbox().distanceTo(x, y)
},
+ insideT: function(x, y) {
+ const box = this.rbox(this.root())
+
+ return (
+ x > box.x && y > box.y && x < box.x + box.width && y < box.y + box.height
+ )
+ },
+
touching: function(x, y, minsize) {
- let b = this.bbox()
+ let b = this.rbox(this.root())
if (b.width < minsize) {
b.x -= (minsize - b.width) / 2
b.width = minsize
@@ -125,6 +133,10 @@ SVG.extend(SVG.Line, {
return this.whereIsPoint(x, y) != null
},
+ insideT: function(x, y) {
+ return this.inside(x, y)
+ },
+
touching: function(x, y, width) {
return this.whereIsPoint(x, y, width) != null
},