mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 08:50:57 -05:00
🐛 Fixed problem when snapping distance outside frame
This commit is contained in:
parent
21613e6614
commit
738a791a27
3 changed files with 7 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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))]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue