mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
🐛 Fix problem when dragging layout children with frames
This commit is contained in:
parent
7ffdf21657
commit
54fd836dd4
2 changed files with 18 additions and 4 deletions
|
@ -109,6 +109,11 @@
|
|||
(recur (conj result parent-id) parent-id)
|
||||
result))))
|
||||
|
||||
(defn get-siblings-ids
|
||||
[objects id]
|
||||
(let [parent (get-parent objects id)]
|
||||
(into [] (->> (:shapes parent) (remove #(= % id))))))
|
||||
|
||||
(defn get-frame
|
||||
"Get the frame that contains the shape. If the shape is already a
|
||||
frame, get itself. If no shape is provided, returns the root frame."
|
||||
|
|
|
@ -435,9 +435,15 @@
|
|||
zoom (get-in state [:workspace-local :zoom] 1)
|
||||
focus (:workspace-focus-selected state)
|
||||
|
||||
exclude-frames (into #{}
|
||||
(filter (partial cph/frame-shape? objects))
|
||||
(cph/selected-with-children objects selected))
|
||||
exclude-frames
|
||||
(into #{}
|
||||
(filter (partial cph/frame-shape? objects))
|
||||
(cph/selected-with-children objects selected))
|
||||
|
||||
exclude-frames-siblings
|
||||
(into exclude-frames
|
||||
(mapcat (partial cph/get-siblings-ids objects))
|
||||
selected)
|
||||
|
||||
fix-axis
|
||||
(fn [[position shift?]]
|
||||
|
@ -471,9 +477,12 @@
|
|||
;; We try to use the previous snap so we don't have to wait for the result of the new
|
||||
(rx/map snap/correct-snap-point)
|
||||
|
||||
(rx/with-latest vector ms/mouse-position-mod)
|
||||
|
||||
(rx/map
|
||||
(fn [move-vector]
|
||||
(fn [[move-vector mod?]]
|
||||
(let [position (gpt/add from-position move-vector)
|
||||
exclude-frames (if mod? exclude-frames exclude-frames-siblings)
|
||||
target-frame (ctst/top-nested-frame objects position exclude-frames)
|
||||
layout? (ctl/layout? objects target-frame)
|
||||
drop-index (when layout? (gsl/get-drop-index target-frame objects position))]
|
||||
|
|
Loading…
Reference in a new issue