mirror of
https://github.com/penpot/penpot.git
synced 2025-05-31 21:51:38 +02:00
♻️ Refactor some page helpers usage
This commit is contained in:
parent
d270c9670e
commit
74c6556ad6
5 changed files with 26 additions and 28 deletions
|
@ -745,24 +745,25 @@
|
|||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
(let [position @ms/mouse-position
|
||||
page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
frame-id (ctt/frame-id-by-position objects position)
|
||||
lookup (d/getf objects)
|
||||
|
||||
moving-shapes
|
||||
(->> ids
|
||||
(cph/clean-loops objects)
|
||||
(keep #(get objects %))
|
||||
(keep (d/getf objects))
|
||||
(remove #(= (:frame-id %) frame-id)))
|
||||
|
||||
moving-frames
|
||||
(->> ids
|
||||
(filter #(cph/frame-shape? objects %)))
|
||||
(filter #(cph/frame-shape? (lookup %)) ids)
|
||||
|
||||
changes (-> (pcb/empty-changes it page-id)
|
||||
(pcb/with-objects objects)
|
||||
(pcb/update-shapes moving-frames (fn [shape] (assoc shape :hide-in-viewer true)))
|
||||
(pcb/change-parent frame-id moving-shapes))]
|
||||
changes
|
||||
(-> (pcb/empty-changes it page-id)
|
||||
(pcb/with-objects objects)
|
||||
(pcb/update-shapes moving-frames (fn [shape] (assoc shape :hide-in-viewer true)))
|
||||
(pcb/change-parent frame-id moving-shapes))]
|
||||
|
||||
(when-not (empty? changes)
|
||||
(rx/of (dch/commit-changes changes)
|
||||
|
|
|
@ -145,7 +145,7 @@
|
|||
on-pointer-move (actions/on-pointer-move viewport-ref zoom move-stream)
|
||||
on-pointer-up (actions/on-pointer-up)
|
||||
on-move-selected (actions/on-move-selected hover hover-ids selected space?)
|
||||
on-menu-selected (actions/on-menu-selected hover hover-ids selected)
|
||||
on-menu-selected (actions/on-menu-selected hover hover-ids selected)
|
||||
|
||||
on-frame-enter (actions/on-frame-enter frame-hover)
|
||||
on-frame-leave (actions/on-frame-leave frame-hover)
|
||||
|
@ -277,7 +277,7 @@
|
|||
[:& outline/shape-outlines
|
||||
{:objects base-objects
|
||||
:hover #{(->> @hover-ids
|
||||
(filter #(cph/frame-shape? base-objects %))
|
||||
(filter #(cph/frame-shape? (get base-objects %)))
|
||||
(remove selected)
|
||||
(first))}
|
||||
:zoom zoom}])
|
||||
|
|
|
@ -188,11 +188,12 @@
|
|||
|
||||
grouped? (fn [id] (contains? #{:group :bool} (get-in objects [id :type])))
|
||||
|
||||
|
||||
selected-with-parents
|
||||
(into #{} (mapcat #(cph/get-parent-ids objects %)) selected)
|
||||
|
||||
root-frame-with-data? #(and (cph/root-frame? objects %) (d/not-empty? (get-in objects [% :shapes])))
|
||||
root-frame-with-data?
|
||||
#(as-> (get objects %) obj
|
||||
(and (cph/root-frame? obj) (d/not-empty? (:shapes obj))))
|
||||
|
||||
;; Set with the elements to remove from the hover list
|
||||
remove-id?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue