mirror of
https://github.com/penpot/penpot.git
synced 2026-01-29 16:51:41 -05:00
Compare commits
2 Commits
develop
...
superalex-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
faa83f664a | ||
|
|
c9cb91a73a |
@@ -527,6 +527,16 @@
|
||||
:else
|
||||
(d/vec2 id default-transform))))))
|
||||
|
||||
(defn- root-only-modif-tree
|
||||
"Restrict modif-tree to shapes whose parent is not in modif-tree (so WASM
|
||||
propagates once; including children would cause double application)."
|
||||
[modif-tree objects]
|
||||
(let [ids-in-tree (set (keys modif-tree))
|
||||
root? (fn [id]
|
||||
(let [parent-id (get-in objects [id :parent-id])]
|
||||
(or (nil? parent-id) (not (ids-in-tree parent-id)))))]
|
||||
(select-keys modif-tree (filter root? (keys modif-tree)))))
|
||||
|
||||
(defn- parse-geometry-modifiers
|
||||
[modif-tree]
|
||||
(into [] xf:parse-geometry-modifier modif-tree))
|
||||
@@ -580,7 +590,7 @@
|
||||
(set-wasm-props! objects prev-wasm-props wasm-props)
|
||||
(let [structure-entries (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 (root-only-modif-tree modif-tree objects))
|
||||
modifiers (wasm.api/propagate-modifiers geometry-entries pixel-precision)]
|
||||
(wasm.api/set-modifiers modifiers)
|
||||
(let [ids (into [] xf:map-key geometry-entries)
|
||||
@@ -637,7 +647,7 @@
|
||||
(assoc :attrs transform-attrs))
|
||||
|
||||
geometry-entries
|
||||
(parse-geometry-modifiers modif-tree)
|
||||
(parse-geometry-modifiers (root-only-modif-tree modif-tree objects))
|
||||
|
||||
snap-pixel?
|
||||
(and (not ignore-snap-pixel) (contains? (:workspace-layout state) :snap-pixel-grid))
|
||||
|
||||
@@ -379,6 +379,8 @@ pub fn propagate_modifiers(
|
||||
modifiers: &[TransformEntry],
|
||||
pixel_precision: bool,
|
||||
) -> Vec<TransformEntry> {
|
||||
// Frontend sends only "root" entries (no child when parent is in the list),
|
||||
// so we don't need to filter here.
|
||||
let mut entries: VecDeque<_> = modifiers
|
||||
.iter()
|
||||
.map(|entry| {
|
||||
@@ -423,7 +425,6 @@ pub fn propagate_modifiers(
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
for id in layout_reflows.iter() {
|
||||
if reflown.contains(id) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user