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

🐛 Adds some guards to viewbox calculation

This commit is contained in:
alonso.torres 2021-04-07 14:28:50 +02:00
parent e8aa521a1e
commit 459c9a3bb1

View file

@ -289,13 +289,13 @@
"Updates the viewbox for groups imported from SVG's" "Updates the viewbox for groups imported from SVG's"
[{:keys [selrect svg-viewbox] :as group} new-selrect] [{:keys [selrect svg-viewbox] :as group} new-selrect]
(let [;; Gets deltas for the selrect to update the svg-viewbox (for svg-imports) (let [;; Gets deltas for the selrect to update the svg-viewbox (for svg-imports)
deltas {:x (- (:x new-selrect) (:x selrect)) deltas {:x (- (:x new-selrect 0) (:x selrect 0))
:y (- (:y new-selrect) (:y selrect)) :y (- (:y new-selrect 0) (:y selrect 0))
:width (- (:width new-selrect) (:width selrect)) :width (- (:width new-selrect 1) (:width selrect 1))
:height (- (:height new-selrect) (:height selrect))}] :height (- (:height new-selrect 1) (:height selrect 1))}]
(cond-> group (cond-> group
svg-viewbox (and (some? svg-viewbox) (some? selrect) (some? new-selrect))
(update :svg-viewbox (update :svg-viewbox
#(-> % #(-> %
(update :x + (:x deltas)) (update :x + (:x deltas))