0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-26 08:29:42 -05:00

🐛 Fix problem when calculating group bounds

This commit is contained in:
alonso.torres 2023-03-31 11:20:42 +02:00
parent d5bbc7b1aa
commit a838dac01b
2 changed files with 41 additions and 29 deletions

View file

@ -133,29 +133,38 @@
(-> (get-shape-filter-bounds shape)
(add-padding (calculate-padding shape true))))
bounds (if (or (:masked-group? shape)
(and (cph/frame-shape? shape)
(not (:show-content shape))))
[(calculate-base-bounds shape)]
(cph/reduce-objects
objects
(fn [shape]
(and (d/not-empty? (:shapes shape))
(or (not (cph/frame-shape? shape))
(:show-content shape))
bounds
(cond
(empty? (:shapes shape))
[(calculate-base-bounds shape)]
(or (not (cph/group-shape? shape))
(not (:masked-group? shape)))))
(:masked-group? shape)
[(calculate-base-bounds shape)]
(:id shape)
(and (cph/frame-shape? shape) (not (:show-content shape)))
[(calculate-base-bounds shape)]
(fn [result shape]
(conj result (get-object-bounds objects shape)))
:else
(cph/reduce-objects
objects
(fn [shape]
(and (d/not-empty? (:shapes shape))
(or (not (cph/frame-shape? shape))
(:show-content shape))
[(calculate-base-bounds shape)]))
(or (not (cph/group-shape? shape))
(not (:masked-group? shape)))))
children-bounds (cond->> (gsr/join-selrects bounds)
(not (cph/frame-shape? shape)) (or (:children-bounds shape)))
(:id shape)
(fn [result child]
(conj result (calculate-base-bounds child)))
[(calculate-base-bounds shape)]))
children-bounds
(cond->> (gsr/join-selrects bounds)
(not (cph/frame-shape? shape)) (or (:children-bounds shape)))
filters (shape->filters shape)
blur-value (or (-> shape :blur :value) 0)]

View file

@ -552,19 +552,22 @@
(loop [current-val init-val
current-id (first root-children)
pending-ids (rest root-children)]
pending-ids (rest root-children)
processed #{}]
(if (contains? processed current-id)
(recur current-val (first pending-ids) (rest pending-ids) processed)
(let [current-shape (get objects current-id)
processed (conj processed current-id)
next-val (reducer-fn current-val current-shape)
next-pending-ids
(if (or (nil? check-children?) (check-children? current-shape))
(concat (or (:shapes current-shape) []) pending-ids)
pending-ids)]
(let [current-shape (get objects current-id)
next-val (reducer-fn current-val current-shape)
next-pending-ids
(if (or (nil? check-children?) (check-children? current-shape))
(concat (or (:shapes current-shape) []) pending-ids)
pending-ids)]
(if (empty? next-pending-ids)
next-val
(recur next-val (first next-pending-ids) (rest next-pending-ids)))))))))
(if (empty? next-pending-ids)
next-val
(recur next-val (first next-pending-ids) (rest next-pending-ids) processed)))))))))
(defn selected-with-children
[objects selected]