0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-14 07:51:35 -05:00

🐛 Fix problem with snap to distances

This commit is contained in:
alonso.torres 2024-01-15 12:55:17 +01:00
parent 03f0724dfd
commit aa7e70141c
2 changed files with 11 additions and 9 deletions

View file

@ -210,8 +210,9 @@
(defn search-snap-distance [selrect coord shapes-lt shapes-gt zoom]
(->> (rx/combine-latest shapes-lt shapes-gt)
(rx/map (fn [[shapes-lt shapes-gt]]
(calculate-snap coord selrect shapes-lt shapes-gt zoom)))))
(rx/map
(fn [[shapes-lt shapes-gt]]
(calculate-snap coord selrect shapes-lt shapes-gt zoom)))))
(defn select-shapes-area
[page-id frame-id selected objects area]
@ -233,12 +234,12 @@
(rx/merge-map
(fn [[frame selrect]]
(let [vbox (deref refs/vbox)
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))
areas (->> (gsh/get-areas
(or (grc/clip-rect (dm/get-prop frame :selrect) vbox)
vbox)
selrect)
areas (->> (gsh/get-areas bounds selrect)
(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-y (search-snap-distance selrect :y (:top areas) (:bottom areas) zoom)]

View file

@ -8,6 +8,7 @@
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.helpers :as cph]
[app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh]
[app.common.math :as mth]
@ -212,9 +213,9 @@
gt-side (if (= coord :x) :right :bottom)
vbox (deref refs/vbox)
areas (gsh/get-areas
(or (grc/clip-rect (dm/get-prop frame :selrect) vbox) vbox)
selrect)
frame-sr (when-not (cph/root? frame) (dm/get-prop frame :selrect))
bounds (d/nilv (grc/clip-rect frame-sr vbox) vbox)
areas (gsh/get-areas bounds selrect)
query-side
(fn [side]