mirror of
https://github.com/penpot/penpot.git
synced 2026-09-13 23:48:42 +00:00
⚡ Skip component-sync on pure-translation drag commits
This commit is contained in:
parent
de9170d96b
commit
27d854ed5b
@ -67,6 +67,12 @@
|
|||||||
(some? undo-group)
|
(some? undo-group)
|
||||||
(assoc :undo-group undo-group)))
|
(assoc :undo-group undo-group)))
|
||||||
|
|
||||||
|
(defn set-translation?
|
||||||
|
[changes translation?]
|
||||||
|
(cond-> changes
|
||||||
|
translation?
|
||||||
|
(assoc :translation? true)))
|
||||||
|
|
||||||
(defn with-page
|
(defn with-page
|
||||||
[changes page]
|
[changes page]
|
||||||
(vary-meta changes assoc
|
(vary-meta changes assoc
|
||||||
|
|||||||
@ -122,7 +122,8 @@
|
|||||||
(defn commit
|
(defn commit
|
||||||
"Create a commit event instance"
|
"Create a commit event instance"
|
||||||
[{:keys [commit-id redo-changes undo-changes origin save-undo? features
|
[{:keys [commit-id redo-changes undo-changes origin save-undo? features
|
||||||
file-id file-revn file-vern undo-group tags stack-undo? source ignore-wasm?]}]
|
file-id file-revn file-vern undo-group tags stack-undo? source ignore-wasm?
|
||||||
|
translation?]}]
|
||||||
|
|
||||||
(assert (cpc/check-changes redo-changes)
|
(assert (cpc/check-changes redo-changes)
|
||||||
"expect valid vector of changes for redo-changes")
|
"expect valid vector of changes for redo-changes")
|
||||||
@ -148,7 +149,8 @@
|
|||||||
:undo-group undo-group
|
:undo-group undo-group
|
||||||
:tags tags
|
:tags tags
|
||||||
:stack-undo? stack-undo?
|
:stack-undo? stack-undo?
|
||||||
:ignore-wasm? ignore-wasm?}]
|
:ignore-wasm? ignore-wasm?
|
||||||
|
:translation? translation?}]
|
||||||
|
|
||||||
(ptk/reify ::commit
|
(ptk/reify ::commit
|
||||||
cljs.core/IDeref
|
cljs.core/IDeref
|
||||||
@ -186,7 +188,8 @@
|
|||||||
- undo-group: if some consecutive changes (or even transactions) share the same
|
- undo-group: if some consecutive changes (or even transactions) share the same
|
||||||
undo-group, they will be undone or redone in a single step
|
undo-group, they will be undone or redone in a single step
|
||||||
"
|
"
|
||||||
[{:keys [redo-changes undo-changes save-undo? undo-group tags stack-undo? file-id]
|
[{:keys [redo-changes undo-changes save-undo? undo-group tags stack-undo? file-id
|
||||||
|
translation?]
|
||||||
:or {save-undo? true
|
:or {save-undo? true
|
||||||
stack-undo? false
|
stack-undo? false
|
||||||
undo-group (uuid/next)
|
undo-group (uuid/next)
|
||||||
@ -216,4 +219,5 @@
|
|||||||
(assoc :file-vern (resolve-file-vern state file-id))
|
(assoc :file-vern (resolve-file-vern state file-id))
|
||||||
(assoc :undo-changes uchg)
|
(assoc :undo-changes uchg)
|
||||||
(assoc :redo-changes rchg)
|
(assoc :redo-changes rchg)
|
||||||
|
(assoc :translation? translation?)
|
||||||
(commit))))))))
|
(commit))))))))
|
||||||
|
|||||||
@ -1382,8 +1382,14 @@
|
|||||||
|
|
||||||
check-changes
|
check-changes
|
||||||
(fn [[event old-data]]
|
(fn [[event old-data]]
|
||||||
(if (nil? old-data)
|
(cond
|
||||||
|
(nil? old-data)
|
||||||
(rx/empty)
|
(rx/empty)
|
||||||
|
|
||||||
|
(:translation? event)
|
||||||
|
(rx/empty)
|
||||||
|
|
||||||
|
:else
|
||||||
(let [{:keys [file-id changes save-undo? undo-group]} event
|
(let [{:keys [file-id changes save-undo? undo-group]} event
|
||||||
|
|
||||||
changed-components
|
changed-components
|
||||||
|
|||||||
@ -659,15 +659,14 @@
|
|||||||
snap-pixel?
|
snap-pixel?
|
||||||
(and (not ignore-snap-pixel) (contains? (:workspace-layout state) :snap-pixel-grid))]
|
(and (not ignore-snap-pixel) (contains? (:workspace-layout state) :snap-pixel-grid))]
|
||||||
(set-wasm-props! objects prev-wasm-props wasm-props)
|
(set-wasm-props! objects prev-wasm-props wasm-props)
|
||||||
(let [structure-entries (parse-structure-modifiers modif-tree)]
|
(wasm.api/set-structure-modifiers (parse-structure-modifiers modif-tree))
|
||||||
(wasm.api/set-structure-modifiers structure-entries)
|
(let [geometry-entries (parse-geometry-modifiers modif-tree)
|
||||||
(let [geometry-entries (parse-geometry-modifiers modif-tree)
|
modifiers (wasm.api/propagate-modifiers geometry-entries snap-pixel?)]
|
||||||
modifiers (wasm.api/propagate-modifiers geometry-entries snap-pixel?)]
|
(wasm.api/set-modifiers modifiers)
|
||||||
(wasm.api/set-modifiers modifiers)
|
(let [ids (into [] xf:map-key geometry-entries)
|
||||||
(let [ids (into [] xf:map-key geometry-entries)
|
selrect (wasm.api/get-selection-rect ids)]
|
||||||
selrect (wasm.api/get-selection-rect ids)]
|
(rx/of (set-temporary-selrect selrect)
|
||||||
(rx/of (set-temporary-selrect selrect)
|
(set-temporary-modifiers modifiers))))))))
|
||||||
(set-temporary-modifiers modifiers)))))))))
|
|
||||||
|
|
||||||
(defn propagate-structure-modifiers
|
(defn propagate-structure-modifiers
|
||||||
[modif-tree objects]
|
[modif-tree objects]
|
||||||
@ -701,8 +700,7 @@
|
|||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
(wasm.api/clean-modifiers)
|
(wasm.api/clean-modifiers)
|
||||||
(let [structure-entries (parse-structure-modifiers modif-tree)]
|
(wasm.api/set-structure-modifiers (parse-structure-modifiers modif-tree))
|
||||||
(wasm.api/set-structure-modifiers structure-entries))
|
|
||||||
|
|
||||||
;; Apply property changes (e.g. grow-type) to WASM shapes before
|
;; Apply property changes (e.g. grow-type) to WASM shapes before
|
||||||
;; propagating geometry, so propagate_modifiers sees the updated state.
|
;; propagating geometry, so propagate_modifiers sees the updated state.
|
||||||
@ -722,6 +720,12 @@
|
|||||||
transforms
|
transforms
|
||||||
(into {} (wasm.api/propagate-modifiers geometry-entries snap-pixel?))
|
(into {} (wasm.api/propagate-modifiers geometry-entries snap-pixel?))
|
||||||
|
|
||||||
|
;; Pure-translation gesture: every shape's modifier only
|
||||||
|
;; contains `:move` operations (no resize/rotate/scale and
|
||||||
|
;; no structural mutation)
|
||||||
|
translation?
|
||||||
|
(every? #(ctm/only-move? (:modifiers %)) (vals modif-tree))
|
||||||
|
|
||||||
ignore-tree
|
ignore-tree
|
||||||
(calculate-ignore-tree-wasm transforms objects)
|
(calculate-ignore-tree-wasm transforms objects)
|
||||||
|
|
||||||
@ -729,6 +733,7 @@
|
|||||||
(-> params
|
(-> params
|
||||||
(assoc :reg-objects? true)
|
(assoc :reg-objects? true)
|
||||||
(assoc :ignore-tree ignore-tree)
|
(assoc :ignore-tree ignore-tree)
|
||||||
|
(assoc :translation? translation?)
|
||||||
;; Attributes that can change in the transform. This
|
;; Attributes that can change in the transform. This
|
||||||
;; way we don't have to check all the attributes
|
;; way we don't have to check all the attributes
|
||||||
(assoc :attrs transform-attrs))
|
(assoc :attrs transform-attrs))
|
||||||
|
|||||||
@ -50,7 +50,7 @@
|
|||||||
([ids update-fn] (update-shapes ids update-fn nil))
|
([ids update-fn] (update-shapes ids update-fn nil))
|
||||||
([ids update-fn
|
([ids update-fn
|
||||||
{:keys [reg-objects? save-undo? stack-undo? attrs ignore-tree page-id
|
{:keys [reg-objects? save-undo? stack-undo? attrs ignore-tree page-id
|
||||||
ignore-touched undo-group with-objects? changed-sub-attr]
|
ignore-touched undo-group with-objects? changed-sub-attr translation?]
|
||||||
:or {reg-objects? false
|
:or {reg-objects? false
|
||||||
save-undo? true
|
save-undo? true
|
||||||
stack-undo? false
|
stack-undo? false
|
||||||
@ -90,7 +90,8 @@
|
|||||||
:ignore-touched ignore-touched
|
:ignore-touched ignore-touched
|
||||||
:with-objects? with-objects?})
|
:with-objects? with-objects?})
|
||||||
(cond-> undo-group
|
(cond-> undo-group
|
||||||
(pcb/set-undo-group undo-group)))
|
(pcb/set-undo-group undo-group))
|
||||||
|
(pcb/set-translation? translation?))
|
||||||
|
|
||||||
changes
|
changes
|
||||||
(add-undo-group changes state)]
|
(add-undo-group changes state)]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user