mirror of
https://github.com/penpot/penpot.git
synced 2025-05-12 03:26:37 +02:00
Merge pull request #1914 from penpot/alotor-performance-improvements
Performance improvements
This commit is contained in:
commit
fa00d674eb
3 changed files with 63 additions and 45 deletions
|
@ -176,6 +176,11 @@
|
|||
|
||||
(defn calc-child-modifiers
|
||||
[parent child modifiers ignore-constraints transformed-parent-rect]
|
||||
|
||||
(if (and (nil? (:resize-vector modifiers))
|
||||
(nil? (:resize-vector-2 modifiers)))
|
||||
;; If we don't have a resize modifier we return the same modifiers
|
||||
modifiers
|
||||
(let [constraints-h
|
||||
(if-not ignore-constraints
|
||||
(:constraints-h child (default-constraints-h child))
|
||||
|
@ -217,4 +222,4 @@
|
|||
:resize-transform-inverse (:resize-transform-inverse modifiers))
|
||||
|
||||
:always
|
||||
(clean-modifiers))))
|
||||
(clean-modifiers)))))
|
||||
|
|
|
@ -356,22 +356,27 @@
|
|||
[modif-tree shape modifiers]
|
||||
|
||||
(let [children (map (d/getf objects) (:shapes shape))
|
||||
modifiers (cond-> modifiers snap-pixel? (set-pixel-precision shape))
|
||||
transformed-rect (gsh/transform-selrect (:selrect shape) modifiers)
|
||||
|
||||
set-child
|
||||
(fn [modif-tree child]
|
||||
(let [child-modifiers (gsh/calc-child-modifiers shape child modifiers ignore-constraints transformed-rect)]
|
||||
(fn [snap-pixel? modif-tree child]
|
||||
(let [child-modifiers (gsh/calc-child-modifiers shape child modifiers ignore-constraints transformed-rect)
|
||||
child-modifiers (cond-> child-modifiers snap-pixel? (set-pixel-precision child))]
|
||||
(cond-> modif-tree
|
||||
(not (gsh/empty-modifiers? child-modifiers))
|
||||
(set-modifiers-rec child child-modifiers))))
|
||||
|
||||
modif-tree
|
||||
(-> modif-tree
|
||||
(assoc-in [(:id shape) :modifiers] modifiers))]
|
||||
(assoc-in [(:id shape) :modifiers] modifiers))
|
||||
|
||||
(reduce set-child modif-tree children)))]
|
||||
(set-modifiers-rec modif-tree shape modifiers)))
|
||||
resize-modif?
|
||||
(or (:resize-vector modifiers) (:resize-vector-2 modifiers))]
|
||||
|
||||
(reduce (partial set-child (and snap-pixel? resize-modif?)) modif-tree children)))]
|
||||
|
||||
(let [modifiers (cond-> modifiers snap-pixel? (set-pixel-precision shape))]
|
||||
(set-modifiers-rec modif-tree shape modifiers))))
|
||||
|
||||
(defn- get-ignore-tree
|
||||
"Retrieves a map with the flag `ignore-geometry?` given a tree of modifiers"
|
||||
|
|
|
@ -28,9 +28,12 @@
|
|||
(defn strip-position-data [shape]
|
||||
(dissoc shape :position-data :transform :transform-inverse))
|
||||
|
||||
(defn strip-modifier
|
||||
[modifier]
|
||||
(d/update-when modifier :modifiers dissoc :displacement :rotation))
|
||||
|
||||
(defn process-shape [modifiers {:keys [id] :as shape}]
|
||||
(let [modifier (get modifiers id)
|
||||
modifier (d/update-when modifier :modifiers dissoc :displacement :rotation)
|
||||
(let [modifier (-> (get modifiers id) strip-modifier)
|
||||
shape (cond-> shape
|
||||
(not (gsh/empty-modifiers? (:modifiers modifier)))
|
||||
(-> (assoc :grow-type :fixed)
|
||||
|
@ -117,11 +120,16 @@
|
|||
text-change?
|
||||
(fn [id]
|
||||
(let [old-shape (get prev-text-shapes id)
|
||||
new-shape (get text-shapes id)]
|
||||
new-shape (get text-shapes id)
|
||||
old-modifiers (-> (get prev-modifiers id) strip-modifier)
|
||||
new-modifiers (-> (get modifiers id) strip-modifier)]
|
||||
(or (and (not (identical? old-shape new-shape))
|
||||
(not= old-shape new-shape))
|
||||
(not= (get modifiers id)
|
||||
(get prev-modifiers id)))))
|
||||
|
||||
;; The shape has changed only if its modifier is not empty and it's different
|
||||
(and (not= new-modifiers old-modifiers)
|
||||
(or (not (gsh/empty-modifiers? (:modifiers old-modifiers)))
|
||||
(not (gsh/empty-modifiers? (:modifiers new-modifiers))))))))
|
||||
|
||||
changed-texts
|
||||
(mf/use-memo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue