mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 15:39:50 -05:00
⚡ Improved performance for root frame movement
This commit is contained in:
parent
ae435f67a5
commit
2f8be445d6
1 changed files with 19 additions and 4 deletions
|
@ -308,6 +308,17 @@
|
||||||
(reduce calculate-modifiers [modif-tree bounds])
|
(reduce calculate-modifiers [modif-tree bounds])
|
||||||
(first))))
|
(first))))
|
||||||
|
|
||||||
|
(defn filter-layouts-ids
|
||||||
|
"Returns a list of ids without the root-frames with only move"
|
||||||
|
[objects modif-tree]
|
||||||
|
(->> modif-tree
|
||||||
|
(remove (fn [[id {:keys [modifiers]}]]
|
||||||
|
(or (ctm/empty? modifiers)
|
||||||
|
(and (cfh/root-frame? objects id)
|
||||||
|
(ctm/only-move? modifiers)))))
|
||||||
|
(map first)
|
||||||
|
(set)))
|
||||||
|
|
||||||
(defn set-objects-modifiers
|
(defn set-objects-modifiers
|
||||||
"Applies recursively the modifiers and calculate the layouts and constraints for all the items to be placed correctly"
|
"Applies recursively the modifiers and calculate the layouts and constraints for all the items to be placed correctly"
|
||||||
([modif-tree objects]
|
([modif-tree objects]
|
||||||
|
@ -331,9 +342,13 @@
|
||||||
(cgt/apply-structure-modifiers modif-tree))
|
(cgt/apply-structure-modifiers modif-tree))
|
||||||
|
|
||||||
;; Creates the sequence of shapes with the shapes that are modified
|
;; Creates the sequence of shapes with the shapes that are modified
|
||||||
shapes-tree
|
shapes-tree-all
|
||||||
(cgst/resolve-tree (-> modif-tree keys set) objects)
|
(cgst/resolve-tree (-> modif-tree keys set) objects)
|
||||||
|
|
||||||
|
;; This second sequence is used to recalculate layouts (we remove moved root-frames)
|
||||||
|
shapes-tree-layout
|
||||||
|
(cgst/resolve-tree (filter-layouts-ids objects modif-tree) objects)
|
||||||
|
|
||||||
bounds-map
|
bounds-map
|
||||||
(cond-> (cgb/objects->bounds-map objects)
|
(cond-> (cgb/objects->bounds-map objects)
|
||||||
(some? old-modif-tree)
|
(some? old-modif-tree)
|
||||||
|
@ -347,13 +362,13 @@
|
||||||
|
|
||||||
;; Propagates the modifiers to the normal shapes with constraints
|
;; Propagates the modifiers to the normal shapes with constraints
|
||||||
modif-tree
|
modif-tree
|
||||||
(propagate-modifiers-constraints objects bounds-map ignore-constraints modif-tree shapes-tree)
|
(propagate-modifiers-constraints objects bounds-map ignore-constraints modif-tree shapes-tree-all)
|
||||||
|
|
||||||
bounds-map
|
bounds-map
|
||||||
(cgb/transform-bounds-map bounds-map objects modif-tree)
|
(cgb/transform-bounds-map bounds-map objects modif-tree)
|
||||||
|
|
||||||
modif-tree-layout
|
modif-tree-layout
|
||||||
(propagate-modifiers-layouts objects bounds-map ignore-constraints shapes-tree)
|
(propagate-modifiers-layouts objects bounds-map ignore-constraints shapes-tree-layout)
|
||||||
|
|
||||||
modif-tree
|
modif-tree
|
||||||
(cgt/merge-modif-tree modif-tree modif-tree-layout)
|
(cgt/merge-modif-tree modif-tree modif-tree-layout)
|
||||||
|
@ -363,7 +378,7 @@
|
||||||
(cgb/transform-bounds-map bounds-map objects modif-tree-layout)
|
(cgb/transform-bounds-map bounds-map objects modif-tree-layout)
|
||||||
|
|
||||||
;; Find layouts with auto width/height
|
;; Find layouts with auto width/height
|
||||||
sizing-auto-layouts (find-auto-layouts objects shapes-tree)
|
sizing-auto-layouts (find-auto-layouts objects shapes-tree-layout)
|
||||||
|
|
||||||
modif-tree
|
modif-tree
|
||||||
(sizing-auto-modifiers modif-tree sizing-auto-layouts objects bounds-map ignore-constraints)
|
(sizing-auto-modifiers modif-tree sizing-auto-layouts objects bounds-map ignore-constraints)
|
||||||
|
|
Loading…
Add table
Reference in a new issue