mirror of
https://github.com/penpot/penpot.git
synced 2025-07-30 07:48:36 +02:00
⚡ Add lightweight optimization to modifiers handling
Mainly using controlled internal mutation when is possible
This commit is contained in:
parent
4a4423da70
commit
3ab67e4545
2 changed files with 103 additions and 33 deletions
|
@ -377,7 +377,15 @@
|
|||
(update [_ state]
|
||||
(assoc state :workspace-modifiers (calculate-modifiers state ignore-constraints ignore-snap-pixel modif-tree params))))))
|
||||
|
||||
;; Rotation use different algorithm to calculate children modifiers (and do not use child constraints).
|
||||
(def ^:private
|
||||
xf-rotation-shape
|
||||
(comp
|
||||
(remove #(get % :blocked false))
|
||||
(filter #(:rotation (get editable-attrs (:type %))))
|
||||
(map :id)))
|
||||
|
||||
;; Rotation use different algorithm to calculate children
|
||||
;; modifiers (and do not use child constraints).
|
||||
(defn set-rotation-modifiers
|
||||
([angle shapes]
|
||||
(set-rotation-modifiers angle shapes (-> shapes gsh/shapes->rect grc/rect->center)))
|
||||
|
@ -387,11 +395,7 @@
|
|||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [objects (wsh/lookup-page-objects state)
|
||||
ids
|
||||
(->> shapes
|
||||
(remove #(get % :blocked false))
|
||||
(filter #(:rotation (get editable-attrs (:type %))))
|
||||
(map :id))
|
||||
ids (sequence xf-rotation-shape shapes)
|
||||
|
||||
get-modifier
|
||||
(fn [shape]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue