mirror of
https://github.com/penpot/penpot.git
synced 2025-05-19 17:26:11 +02:00
⚡ Improved text move performance
This commit is contained in:
parent
9ab922a0fa
commit
a8cc9ace72
1 changed files with 13 additions and 5 deletions
|
@ -28,9 +28,12 @@
|
||||||
(defn strip-position-data [shape]
|
(defn strip-position-data [shape]
|
||||||
(dissoc shape :position-data :transform :transform-inverse))
|
(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}]
|
(defn process-shape [modifiers {:keys [id] :as shape}]
|
||||||
(let [modifier (get modifiers id)
|
(let [modifier (-> (get modifiers id) strip-modifier)
|
||||||
modifier (d/update-when modifier :modifiers dissoc :displacement :rotation)
|
|
||||||
shape (cond-> shape
|
shape (cond-> shape
|
||||||
(not (gsh/empty-modifiers? (:modifiers modifier)))
|
(not (gsh/empty-modifiers? (:modifiers modifier)))
|
||||||
(-> (assoc :grow-type :fixed)
|
(-> (assoc :grow-type :fixed)
|
||||||
|
@ -117,11 +120,16 @@
|
||||||
text-change?
|
text-change?
|
||||||
(fn [id]
|
(fn [id]
|
||||||
(let [old-shape (get prev-text-shapes 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))
|
(or (and (not (identical? old-shape new-shape))
|
||||||
(not= 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
|
changed-texts
|
||||||
(mf/use-memo
|
(mf/use-memo
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue