🐛 Fixed measurements showing with itself

This commit is contained in:
alonso.torres 2021-01-28 14:34:00 +01:00
parent 8f1b373c3d
commit fd620a858c

View file

@ -205,6 +205,7 @@
(let [center-x (+ x1 (/ (- x2 x1) 2)) (let [center-x (+ x1 (/ (- x2 x1) 2))
center-y (+ y1 (/ (- y2 y1) 2)) center-y (+ y1 (/ (- y2 y1) 2))
distance (gpt/distance (gpt/point x1 y1) (gpt/point x2 y2))] distance (gpt/distance (gpt/point x1 y1) (gpt/point x2 y2))]
(when-not (mth/almost-zero? distance)
[:g.distance-line {:key (str "line-%s-%s-%s-%s" x1 y1 x2 y2)} [:g.distance-line {:key (str "line-%s-%s-%s-%s" x1 y1 x2 y2)}
[:line [:line
{:x1 x1 {:x1 x1
@ -219,7 +220,7 @@
:y center-y :y center-y
:zoom zoom :zoom zoom
:distance (str (mth/round distance) "px") :distance (str (mth/round distance) "px")
:bounds bounds}]])))) :bounds bounds}]])))))
(mf/defc selection-guides [{:keys [bounds selrect zoom]}] (mf/defc selection-guides [{:keys [bounds selrect zoom]}]
[:g.selection-guides [:g.selection-guides
@ -233,11 +234,12 @@
:stroke-dasharray (/ select-guide-dasharray zoom)}}])]) :stroke-dasharray (/ select-guide-dasharray zoom)}}])])
(mf/defc measurement [{:keys [bounds frame selected-shapes hover-shape zoom]}] (mf/defc measurement [{:keys [bounds frame selected-shapes hover-shape zoom]}]
(let [selected-selrect (gsh/selection-rect selected-shapes) (let [selected-ids (into #{} (map :id) selected-shapes)
selected-selrect (gsh/selection-rect selected-shapes)
hover-selrect (:selrect hover-shape) hover-selrect (:selrect hover-shape)
bounds-selrect (bound->selrect bounds)] bounds-selrect (bound->selrect bounds)]
(when (seq selected-shapes) (when (and (seq selected-shapes) (not (contains? selected-ids (:id hover-shape))))
[:g.measurement-feedback {:pointer-events "none"} [:g.measurement-feedback {:pointer-events "none"}
[:& selection-guides {:selrect selected-selrect :bounds bounds :zoom zoom}] [:& selection-guides {:selrect selected-selrect :bounds bounds :zoom zoom}]
[:& size-display {:selrect selected-selrect :zoom zoom}] [:& size-display {:selrect selected-selrect :zoom zoom}]