diff --git a/common/src/app/common/pages/helpers.cljc b/common/src/app/common/pages/helpers.cljc index 76e234f57..b9bf67b7e 100644 --- a/common/src/app/common/pages/helpers.cljc +++ b/common/src/app/common/pages/helpers.cljc @@ -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." diff --git a/frontend/src/app/main/data/workspace/transforms.cljs b/frontend/src/app/main/data/workspace/transforms.cljs index 2658720ef..be5bf599c 100644 --- a/frontend/src/app/main/data/workspace/transforms.cljs +++ b/frontend/src/app/main/data/workspace/transforms.cljs @@ -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))]