mirror of
https://github.com/penpot/penpot.git
synced 2025-06-03 05:41:37 +02:00
🐛 Fix problem with thumbnails for empty pages
This commit is contained in:
parent
95868416ef
commit
3aadf00a6f
1 changed files with 19 additions and 11 deletions
|
@ -67,8 +67,15 @@
|
||||||
|
|
||||||
(defn- calculate-dimensions
|
(defn- calculate-dimensions
|
||||||
[objects aspect-ratio]
|
[objects aspect-ratio]
|
||||||
|
(let [root-objects (ctst/get-root-objects objects)]
|
||||||
|
(if (empty? root-objects)
|
||||||
|
;; Empty page, we create an arbitrary rect for the thumbnail
|
||||||
|
(-> (grc/make-rect {:x 0 :y 0 :width 100 :height 100})
|
||||||
|
(grc/update-rect :position)
|
||||||
|
(grc/fix-aspect-ratio aspect-ratio))
|
||||||
|
|
||||||
(let [bounds
|
(let [bounds
|
||||||
(->> (ctst/get-root-objects objects)
|
(->> root-objects
|
||||||
(map (partial gsb/get-object-bounds objects))
|
(map (partial gsb/get-object-bounds objects))
|
||||||
(grc/join-rects))]
|
(grc/join-rects))]
|
||||||
(-> bounds
|
(-> bounds
|
||||||
|
@ -77,7 +84,7 @@
|
||||||
(update :width mth/finite 100000)
|
(update :width mth/finite 100000)
|
||||||
(update :height mth/finite 100000)
|
(update :height mth/finite 100000)
|
||||||
(grc/update-rect :position)
|
(grc/update-rect :position)
|
||||||
(grc/fix-aspect-ratio aspect-ratio))))
|
(grc/fix-aspect-ratio aspect-ratio))))))
|
||||||
|
|
||||||
(declare shape-wrapper-factory)
|
(declare shape-wrapper-factory)
|
||||||
|
|
||||||
|
@ -201,6 +208,7 @@
|
||||||
(let [objects (:objects data)
|
(let [objects (:objects data)
|
||||||
shapes (cfh/get-immediate-children objects)
|
shapes (cfh/get-immediate-children objects)
|
||||||
dim (calculate-dimensions objects aspect-ratio)
|
dim (calculate-dimensions objects aspect-ratio)
|
||||||
|
_ (prn ">>DIM" dim)
|
||||||
vbox (format-viewbox dim)
|
vbox (format-viewbox dim)
|
||||||
bgcolor (dm/get-in data [:options :background] default-color)
|
bgcolor (dm/get-in data [:options :background] default-color)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue