From 738a791a27a1ace6f58d3f496c3736a04ee23fb2 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 29 May 2020 09:20:33 +0200 Subject: [PATCH] :bug: Fixed problem when snapping distance outside frame --- frontend/src/uxbox/main/refs.cljs | 3 +++ frontend/src/uxbox/main/snap.cljs | 3 ++- frontend/src/uxbox/main/ui/workspace/snap_distances.cljs | 6 ++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/src/uxbox/main/refs.cljs b/frontend/src/uxbox/main/refs.cljs index 2437461b3..b232e0ec6 100644 --- a/frontend/src/uxbox/main/refs.cljs +++ b/frontend/src/uxbox/main/refs.cljs @@ -144,6 +144,9 @@ (def options-mode (l/derived :options-mode workspace-local)) +(def vbox + (l/derived :vbox workspace-local)) + ;; ---- Viewer refs (def viewer-data diff --git a/frontend/src/uxbox/main/snap.cljs b/frontend/src/uxbox/main/snap.cljs index 55287be3f..87bf26e73 100644 --- a/frontend/src/uxbox/main/snap.cljs +++ b/frontend/src/uxbox/main/snap.cljs @@ -17,6 +17,7 @@ [uxbox.common.geom.point :as gpt] [uxbox.common.geom.shapes :as gsh] [uxbox.main.worker :as uw] + [uxbox.main.refs :as refs] [uxbox.util.geom.snap-points :as sp])) (def ^:private snap-accuracy 5) @@ -161,7 +162,7 @@ (-> % gsh/selection-rect (gsh/move movev)))) (rx/merge-map (fn [[frame selrect]] - (let [areas (->> (gsh/selrect->areas (:selrect frame) selrect) + (let [areas (->> (gsh/selrect->areas (or (:selrect frame) @refs/vbox) selrect) (d/mapm #(select-shapes-area page-id shapes objects %2))) snap-x (search-snap-distance selrect :x (:left areas) (:right areas)) snap-y (search-snap-distance selrect :y (:top areas) (:bottom areas))] diff --git a/frontend/src/uxbox/main/ui/workspace/snap_distances.cljs b/frontend/src/uxbox/main/ui/workspace/snap_distances.cljs index f51b64e07..96e5030aa 100644 --- a/frontend/src/uxbox/main/ui/workspace/snap_distances.cljs +++ b/frontend/src/uxbox/main/ui/workspace/snap_distances.cljs @@ -54,7 +54,6 @@ distance (mth/round (- to-c from-c)) half-point (half-point coord sr1 sr2) - text-ref (mf/use-ref nil) width (-> distance mth/log10 ;; number of digits (* (/ pill-text-width-letter zoom)) @@ -75,8 +74,7 @@ :rx (/ pill-text-border-radius zoom) :fill line-color}] - [:text {:ref text-ref - :x (if (= coord :x) x (+ x (/ width 2))) + [:text {:x (if (= coord :x) x (+ x (/ width 2))) :y (- (+ y (/ (/ pill-text-height zoom) 2) (- (/ 6 zoom))) (if (= coord :x) (/ 2 zoom) 0)) :font-size (/ pill-text-font-size zoom) :fill "white" @@ -125,7 +123,7 @@ (fn [[selrect selected frame]] (let [lt-side (if (= coord :x) :left :top) gt-side (if (= coord :x) :right :bottom) - areas (gsh/selrect->areas (:selrect frame) selrect) + areas (gsh/selrect->areas (or (:selrect frame) @refs/vbox) selrect) query-side (fn [side] (->> (uw/ask! {:cmd :selection/query :page-id page-id