0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 23:18:48 -05:00

🐛 Fix problem in viewer with hidden elements

This commit is contained in:
alonso.torres 2024-01-19 14:28:06 +01:00
parent 844634e8c8
commit 02044a8153
3 changed files with 22 additions and 19 deletions

View file

@ -140,40 +140,41 @@
(update :width + (* 2 h-padding))
(update :height + (* 2 v-padding)))))
(defn calculate-base-bounds
[shape]
(-> (get-shape-filter-bounds shape)
(add-padding (calculate-padding shape true))))
(defn get-object-bounds
[objects shape]
(let [calculate-base-bounds
(fn [shape]
(-> (get-shape-filter-bounds shape)
(add-padding (calculate-padding shape true))))
(let [base-bounds (calculate-base-bounds shape)
bounds
(cond
(empty? (:shapes shape))
[(calculate-base-bounds shape)]
(or (:masked-group shape) (= :bool (:type shape)))
[(calculate-base-bounds shape)]
(and (cfh/frame-shape? shape) (not (:show-content shape)))
[(calculate-base-bounds shape)]
(or (empty? (:shapes shape))
(or (:masked-group shape) (= :bool (:type shape)))
(and (cfh/frame-shape? shape) (not (:show-content shape))))
[base-bounds]
:else
(cfh/reduce-objects
objects
(fn [shape]
(and (d/not-empty? (:shapes shape))
(and (not (:hidden shape))
(d/not-empty? (:shapes shape))
(or (not (cfh/frame-shape? shape))
(:show-content shape))
(or (not (cfh/group-shape? shape))
(not (:masked-group shape)))))
(:id shape)
(fn [result child]
(conj result (calculate-base-bounds child)))
[(calculate-base-bounds shape)]))
(fn [result child]
(cond-> result
(not (:hidden child))
(conj (calculate-base-bounds child))))
[base-bounds]))
children-bounds
(cond->> (grc/join-rects bounds)

View file

@ -91,7 +91,7 @@
[{:keys [shape]}]
[:*
(when ^boolean (dbg/enabled? :bounding-boxes)
[:& debug-bounding-boxes])
[:& debug-bounding-boxes {:shape shape}])
(when (and ^boolean (cfh/text-shape? shape)
^boolean (dbg/enabled? :text-outline)

View file

@ -44,7 +44,9 @@
childs (mf/deref childs-ref)]
[:& shape-container {:shape shape :ref ref :disable-shadows? (cfh/is-direct-child-of-root? shape)}
[:& frame-shape {:shape shape :childs childs}]]))))
[:& frame-shape {:shape shape :childs childs}]
(when *assert*
[:& wsd/shape-debug {:shape shape}])]))))
(defn check-props
[new-props old-props]