0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 08:20:45 -05:00

Merge pull request #176 from uxbox/239/select-with-zoom

🐛 Take into account zoom when selecting objects with rect
This commit is contained in:
Andrey Antukh 2020-04-14 12:59:24 +02:00 committed by GitHub
commit b24307cf35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -1169,17 +1169,19 @@
(defn impl-match-by-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])
match (fn [acc {:keys [type id] :as shape}]
(cond
(helpers/is-shape-grouped (:id shape) (:objects data))
acc
(geom/contained-in? shape selrect)
(geom/contained-in? shape selrect')
(conj acc id)
(geom/overlaps? shape selrect)
(geom/overlaps? shape selrect')
(conj acc id)
:else

View file

@ -701,6 +701,14 @@
;; --- 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?
"Check if a shape is contained in the
provided selection rect."