mirror of
https://github.com/penpot/penpot.git
synced 2025-06-03 05:51:38 +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,17 +67,24 @@
|
||||||
|
|
||||||
(defn- calculate-dimensions
|
(defn- calculate-dimensions
|
||||||
[objects aspect-ratio]
|
[objects aspect-ratio]
|
||||||
(let [bounds
|
(let [root-objects (ctst/get-root-objects objects)]
|
||||||
(->> (ctst/get-root-objects objects)
|
(if (empty? root-objects)
|
||||||
(map (partial gsb/get-object-bounds objects))
|
;; Empty page, we create an arbitrary rect for the thumbnail
|
||||||
(grc/join-rects))]
|
(-> (grc/make-rect {:x 0 :y 0 :width 100 :height 100})
|
||||||
(-> bounds
|
(grc/update-rect :position)
|
||||||
(update :x mth/finite 0)
|
(grc/fix-aspect-ratio aspect-ratio))
|
||||||
(update :y mth/finite 0)
|
|
||||||
(update :width mth/finite 100000)
|
(let [bounds
|
||||||
(update :height mth/finite 100000)
|
(->> root-objects
|
||||||
(grc/update-rect :position)
|
(map (partial gsb/get-object-bounds objects))
|
||||||
(grc/fix-aspect-ratio aspect-ratio))))
|
(grc/join-rects))]
|
||||||
|
(-> bounds
|
||||||
|
(update :x mth/finite 0)
|
||||||
|
(update :y mth/finite 0)
|
||||||
|
(update :width mth/finite 100000)
|
||||||
|
(update :height mth/finite 100000)
|
||||||
|
(grc/update-rect :position)
|
||||||
|
(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