mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 15:39:50 -05:00
🐛 Take into account zoom when selecting objects with rect
This commit is contained in:
parent
043cf27ace
commit
3fd1513128
2 changed files with 13 additions and 3 deletions
|
@ -1169,17 +1169,19 @@
|
||||||
|
|
||||||
(defn impl-match-by-selrect
|
(defn impl-match-by-selrect
|
||||||
[state selrect]
|
[state selrect]
|
||||||
(let [page-id (::page-id state)
|
(let [zoom (gpt/point (get-in state [:workspace-local :zoom]))
|
||||||
|
selrect' (geom/apply-zoom selrect zoom)
|
||||||
|
page-id (::page-id state)
|
||||||
data (get-in state [:workspace-data page-id])
|
data (get-in state [:workspace-data page-id])
|
||||||
match (fn [acc {:keys [type id] :as shape}]
|
match (fn [acc {:keys [type id] :as shape}]
|
||||||
(cond
|
(cond
|
||||||
(helpers/is-shape-grouped (:id shape) (:objects data))
|
(helpers/is-shape-grouped (:id shape) (:objects data))
|
||||||
acc
|
acc
|
||||||
|
|
||||||
(geom/contained-in? shape selrect)
|
(geom/contained-in? shape selrect')
|
||||||
(conj acc id)
|
(conj acc id)
|
||||||
|
|
||||||
(geom/overlaps? shape selrect)
|
(geom/overlaps? shape selrect')
|
||||||
(conj acc id)
|
(conj acc id)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
|
|
|
@ -701,6 +701,14 @@
|
||||||
|
|
||||||
;; --- Helpers
|
;; --- Helpers
|
||||||
|
|
||||||
|
(defn apply-zoom
|
||||||
|
[selrect zoom]
|
||||||
|
(assoc selrect
|
||||||
|
:x (/ (:x selrect) (:x zoom))
|
||||||
|
:y (/ (:y selrect) (:y zoom))
|
||||||
|
:width (/ (:width selrect) (:x zoom))
|
||||||
|
:height (/ (:height selrect) (:y zoom))))
|
||||||
|
|
||||||
(defn contained-in?
|
(defn contained-in?
|
||||||
"Check if a shape is contained in the
|
"Check if a shape is contained in the
|
||||||
provided selection rect."
|
provided selection rect."
|
||||||
|
|
Loading…
Add table
Reference in a new issue