mirror of
https://github.com/penpot/penpot.git
synced 2026-08-01 19:06:18 +00:00
⚡ Skip grid reorder and changed-attrs walk on translation commits
This commit is contained in:
parent
350d97d069
commit
5a2d982d04
@ -75,7 +75,7 @@
|
|||||||
(reduce check-shape changes mod-obj-changes)))
|
(reduce check-shape changes mod-obj-changes)))
|
||||||
|
|
||||||
(defn generate-update-shapes
|
(defn generate-update-shapes
|
||||||
[changes ids update-fn objects {:keys [attrs changed-sub-attr ignore-tree ignore-touched with-objects?]}]
|
[changes ids update-fn objects {:keys [attrs changed-sub-attr ignore-tree ignore-touched with-objects? translation?]}]
|
||||||
(let [changes (reduce
|
(let [changes (reduce
|
||||||
(fn [changes id]
|
(fn [changes id]
|
||||||
(let [opts {:attrs attrs
|
(let [opts {:attrs attrs
|
||||||
@ -86,13 +86,19 @@
|
|||||||
(-> changes
|
(-> changes
|
||||||
(pcb/with-objects objects))
|
(pcb/with-objects objects))
|
||||||
ids)
|
ids)
|
||||||
grid-ids (->> ids (filter (partial ctl/grid-layout? objects)))
|
;; Translation doesn't shift children between grid cells, so
|
||||||
changes (-> changes
|
;; cell reassignment + child reorder are no-ops with a per-grid
|
||||||
(pcb/update-shapes grid-ids ctl/assign-cell-positions {:with-objects? true})
|
;; cost. Skipping them on translation-only commits removes the
|
||||||
(pcb/reorder-grid-children ids)
|
;; grid-layout reflow from the on-drop hot path.
|
||||||
(cond->
|
grid-ids (when-not translation?
|
||||||
(not ignore-touched)
|
(->> ids (filter (partial ctl/grid-layout? objects))))
|
||||||
(generate-unapply-tokens objects changed-sub-attr)))]
|
changes (cond-> changes
|
||||||
|
(seq grid-ids)
|
||||||
|
(-> (pcb/update-shapes grid-ids ctl/assign-cell-positions {:with-objects? true})
|
||||||
|
(pcb/reorder-grid-children ids))
|
||||||
|
|
||||||
|
(not ignore-touched)
|
||||||
|
(generate-unapply-tokens objects changed-sub-attr))]
|
||||||
changes))
|
changes))
|
||||||
|
|
||||||
(defn- generate-update-shape-flags
|
(defn- generate-update-shape-flags
|
||||||
|
|||||||
@ -73,9 +73,16 @@
|
|||||||
(filter #(some update-layout-attr? (pcb/changed-attrs % objects update-fn {:attrs attrs :with-objects? with-objects?})))
|
(filter #(some update-layout-attr? (pcb/changed-attrs % objects update-fn {:attrs attrs :with-objects? with-objects?})))
|
||||||
(map :id))
|
(map :id))
|
||||||
|
|
||||||
|
;; `xf-update-layout` runs `update-fn` + attr diff for
|
||||||
|
;; every id just to decide whether to dispatch
|
||||||
|
;; `:layout/update`. `update-layout-attr?` is `#{:hidden}`,
|
||||||
|
;; so a pure-translation commit can never trigger it —
|
||||||
|
;; skip the N×diff walk on drop-of-layout-drag (the hot
|
||||||
|
;; on-drop path for layouts with many children).
|
||||||
update-layout-ids
|
update-layout-ids
|
||||||
(->> (into [] xf-update-layout ids)
|
(when-not translation?
|
||||||
(not-empty))
|
(->> (into [] xf-update-layout ids)
|
||||||
|
(not-empty)))
|
||||||
|
|
||||||
changes
|
changes
|
||||||
(-> (pcb/empty-changes it page-id)
|
(-> (pcb/empty-changes it page-id)
|
||||||
@ -88,7 +95,8 @@
|
|||||||
:changed-sub-attr changed-sub-attr
|
:changed-sub-attr changed-sub-attr
|
||||||
:ignore-tree ignore-tree
|
:ignore-tree ignore-tree
|
||||||
:ignore-touched ignore-touched
|
:ignore-touched ignore-touched
|
||||||
:with-objects? with-objects?})
|
:with-objects? with-objects?
|
||||||
|
:translation? translation?})
|
||||||
(cond-> undo-group
|
(cond-> undo-group
|
||||||
(pcb/set-undo-group undo-group))
|
(pcb/set-undo-group undo-group))
|
||||||
(pcb/set-translation? translation?))
|
(pcb/set-translation? translation?))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user