mirror of
https://github.com/penpot/penpot.git
synced 2025-07-17 03:05:18 +02:00
🐛 Fix problem with snap to distances
This commit is contained in:
parent
03f0724dfd
commit
aa7e70141c
2 changed files with 11 additions and 9 deletions
|
@ -210,8 +210,9 @@
|
||||||
|
|
||||||
(defn search-snap-distance [selrect coord shapes-lt shapes-gt zoom]
|
(defn search-snap-distance [selrect coord shapes-lt shapes-gt zoom]
|
||||||
(->> (rx/combine-latest shapes-lt shapes-gt)
|
(->> (rx/combine-latest shapes-lt shapes-gt)
|
||||||
(rx/map (fn [[shapes-lt shapes-gt]]
|
(rx/map
|
||||||
(calculate-snap coord selrect shapes-lt shapes-gt zoom)))))
|
(fn [[shapes-lt shapes-gt]]
|
||||||
|
(calculate-snap coord selrect shapes-lt shapes-gt zoom)))))
|
||||||
|
|
||||||
(defn select-shapes-area
|
(defn select-shapes-area
|
||||||
[page-id frame-id selected objects area]
|
[page-id frame-id selected objects area]
|
||||||
|
@ -233,12 +234,12 @@
|
||||||
(rx/merge-map
|
(rx/merge-map
|
||||||
(fn [[frame selrect]]
|
(fn [[frame selrect]]
|
||||||
(let [vbox (deref refs/vbox)
|
(let [vbox (deref refs/vbox)
|
||||||
|
|
||||||
frame-id (->> shapes first :frame-id)
|
frame-id (->> shapes first :frame-id)
|
||||||
|
frame-sr (when-not (cfh/root? frame) (dm/get-prop frame :selrect))
|
||||||
|
bounds (d/nilv (grc/clip-rect frame-sr vbox) vbox)
|
||||||
selected (into #{} (map :id shapes))
|
selected (into #{} (map :id shapes))
|
||||||
areas (->> (gsh/get-areas
|
areas (->> (gsh/get-areas bounds selrect)
|
||||||
(or (grc/clip-rect (dm/get-prop frame :selrect) vbox)
|
|
||||||
vbox)
|
|
||||||
selrect)
|
|
||||||
(d/mapm #(select-shapes-area page-id frame-id selected objects %2)))
|
(d/mapm #(select-shapes-area page-id frame-id selected objects %2)))
|
||||||
snap-x (search-snap-distance selrect :x (:left areas) (:right areas) zoom)
|
snap-x (search-snap-distance selrect :x (:left areas) (:right areas) zoom)
|
||||||
snap-y (search-snap-distance selrect :y (:top areas) (:bottom areas) zoom)]
|
snap-y (search-snap-distance selrect :y (:top areas) (:bottom areas) zoom)]
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
|
[app.common.files.helpers :as cph]
|
||||||
[app.common.geom.rect :as grc]
|
[app.common.geom.rect :as grc]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
|
@ -212,9 +213,9 @@
|
||||||
gt-side (if (= coord :x) :right :bottom)
|
gt-side (if (= coord :x) :right :bottom)
|
||||||
|
|
||||||
vbox (deref refs/vbox)
|
vbox (deref refs/vbox)
|
||||||
areas (gsh/get-areas
|
frame-sr (when-not (cph/root? frame) (dm/get-prop frame :selrect))
|
||||||
(or (grc/clip-rect (dm/get-prop frame :selrect) vbox) vbox)
|
bounds (d/nilv (grc/clip-rect frame-sr vbox) vbox)
|
||||||
selrect)
|
areas (gsh/get-areas bounds selrect)
|
||||||
|
|
||||||
query-side
|
query-side
|
||||||
(fn [side]
|
(fn [side]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue