mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 15:41:38 +02: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
|
(def options-mode
|
||||||
(l/derived :options-mode workspace-local))
|
(l/derived :options-mode workspace-local))
|
||||||
|
|
||||||
|
(def vbox
|
||||||
|
(l/derived :vbox workspace-local))
|
||||||
|
|
||||||
;; ---- Viewer refs
|
;; ---- Viewer refs
|
||||||
|
|
||||||
(def viewer-data
|
(def viewer-data
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
[uxbox.common.geom.point :as gpt]
|
[uxbox.common.geom.point :as gpt]
|
||||||
[uxbox.common.geom.shapes :as gsh]
|
[uxbox.common.geom.shapes :as gsh]
|
||||||
[uxbox.main.worker :as uw]
|
[uxbox.main.worker :as uw]
|
||||||
|
[uxbox.main.refs :as refs]
|
||||||
[uxbox.util.geom.snap-points :as sp]))
|
[uxbox.util.geom.snap-points :as sp]))
|
||||||
|
|
||||||
(def ^:private snap-accuracy 5)
|
(def ^:private snap-accuracy 5)
|
||||||
|
@ -161,7 +162,7 @@
|
||||||
(-> % gsh/selection-rect (gsh/move movev))))
|
(-> % gsh/selection-rect (gsh/move movev))))
|
||||||
(rx/merge-map
|
(rx/merge-map
|
||||||
(fn [[frame selrect]]
|
(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)))
|
(d/mapm #(select-shapes-area page-id shapes objects %2)))
|
||||||
snap-x (search-snap-distance selrect :x (:left areas) (:right areas))
|
snap-x (search-snap-distance selrect :x (:left areas) (:right areas))
|
||||||
snap-y (search-snap-distance selrect :y (:top areas) (:bottom areas))]
|
snap-y (search-snap-distance selrect :y (:top areas) (:bottom areas))]
|
||||||
|
|
|
@ -54,7 +54,6 @@
|
||||||
|
|
||||||
distance (mth/round (- to-c from-c))
|
distance (mth/round (- to-c from-c))
|
||||||
half-point (half-point coord sr1 sr2)
|
half-point (half-point coord sr1 sr2)
|
||||||
text-ref (mf/use-ref nil)
|
|
||||||
width (-> distance
|
width (-> distance
|
||||||
mth/log10 ;; number of digits
|
mth/log10 ;; number of digits
|
||||||
(* (/ pill-text-width-letter zoom))
|
(* (/ pill-text-width-letter zoom))
|
||||||
|
@ -75,8 +74,7 @@
|
||||||
:rx (/ pill-text-border-radius zoom)
|
:rx (/ pill-text-border-radius zoom)
|
||||||
:fill line-color}]
|
:fill line-color}]
|
||||||
|
|
||||||
[:text {:ref text-ref
|
[:text {:x (if (= coord :x) x (+ x (/ width 2)))
|
||||||
:x (if (= coord :x) x (+ x (/ width 2)))
|
|
||||||
:y (- (+ y (/ (/ pill-text-height zoom) 2) (- (/ 6 zoom))) (if (= coord :x) (/ 2 zoom) 0))
|
:y (- (+ y (/ (/ pill-text-height zoom) 2) (- (/ 6 zoom))) (if (= coord :x) (/ 2 zoom) 0))
|
||||||
:font-size (/ pill-text-font-size zoom)
|
:font-size (/ pill-text-font-size zoom)
|
||||||
:fill "white"
|
:fill "white"
|
||||||
|
@ -125,7 +123,7 @@
|
||||||
(fn [[selrect selected frame]]
|
(fn [[selrect selected frame]]
|
||||||
(let [lt-side (if (= coord :x) :left :top)
|
(let [lt-side (if (= coord :x) :left :top)
|
||||||
gt-side (if (= coord :x) :right :bottom)
|
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]
|
query-side (fn [side]
|
||||||
(->> (uw/ask! {:cmd :selection/query
|
(->> (uw/ask! {:cmd :selection/query
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue