0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-12 07:41:43 -05:00

Match selrect selection by overlap instead of strictly contained-in.

This commit is contained in:
Andrey Antukh 2017-02-23 20:45:13 +01:00
parent 4ba4fb3acb
commit bb0b616cb3
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
2 changed files with 13 additions and 0 deletions

View file

@ -286,6 +286,9 @@
(geom/contained-in? shape selrect) (geom/contained-in? shape selrect)
(conj acc id) (conj acc id)
(geom/overlaps? shape selrect)
(conj acc id)
(:locked shape) (:locked shape)
acc acc

View file

@ -564,3 +564,13 @@
(neg? (- sx1 rx1)) (neg? (- sx1 rx1))
(pos? (- sy2 ry2)) (pos? (- sy2 ry2))
(pos? (- sx2 rx2))))) (pos? (- sx2 rx2)))))
(defn overlaps?
"Check if a shape overlaps with provided selection rect."
[shape selrect]
(let [{sx1 :x1 sx2 :x2 sy1 :y1 sy2 :y2} selrect
{rx1 :x1 rx2 :x2 ry1 :y1 ry2 :y2} shape]
(and (< rx1 sx2)
(> rx2 sx1)
(< ry1 sy2)
(> ry2 sy1))))