From bb0b616cb3ac49fb9483f2d1076b0bb5fb1ac916 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 23 Feb 2017 20:45:13 +0100 Subject: [PATCH] Match selrect selection by overlap instead of strictly contained-in. --- frontend/src/uxbox/main/data/shapes_impl.cljs | 3 +++ frontend/src/uxbox/main/geom.cljs | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/frontend/src/uxbox/main/data/shapes_impl.cljs b/frontend/src/uxbox/main/data/shapes_impl.cljs index 1c5411356..598445bf4 100644 --- a/frontend/src/uxbox/main/data/shapes_impl.cljs +++ b/frontend/src/uxbox/main/data/shapes_impl.cljs @@ -286,6 +286,9 @@ (geom/contained-in? shape selrect) (conj acc id) + (geom/overlaps? shape selrect) + (conj acc id) + (:locked shape) acc diff --git a/frontend/src/uxbox/main/geom.cljs b/frontend/src/uxbox/main/geom.cljs index 37f19623b..9ee43c887 100644 --- a/frontend/src/uxbox/main/geom.cljs +++ b/frontend/src/uxbox/main/geom.cljs @@ -564,3 +564,13 @@ (neg? (- sx1 rx1)) (pos? (- sy2 ry2)) (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))))