mirror of
https://github.com/penpot/penpot.git
synced 2025-07-30 09:58:31 +02:00
🐛 Fix incorrect bounds calc on svg-defs
This commit is contained in:
parent
aa8300c085
commit
807f475a2d
1 changed files with 28 additions and 26 deletions
|
@ -90,22 +90,23 @@
|
||||||
:transform transform
|
:transform transform
|
||||||
:bounds bounds}])]])))
|
:bounds bounds}])]])))
|
||||||
|
|
||||||
(defn svg-def-bounds [svg-def shape transform]
|
(defn- get-svg-def-bounds
|
||||||
(let [{:keys [tag]} svg-def]
|
[{:keys [tag attrs] :as node} shape transform]
|
||||||
(if (or (= tag :mask) (contains? csvg/filter-tags tag))
|
(if (or (= tag :mask) (contains? csvg/filter-tags tag))
|
||||||
(-> (grc/make-rect (d/parse-double (get-in svg-def [:attrs :x]))
|
(some-> (grc/make-rect (d/parse-double (get attrs :x))
|
||||||
(d/parse-double (get-in svg-def [:attrs :y]))
|
(d/parse-double (get attrs :y))
|
||||||
(d/parse-double (get-in svg-def [:attrs :width]))
|
(d/parse-double (get attrs :width))
|
||||||
(d/parse-double (get-in svg-def [:attrs :height])))
|
(d/parse-double (get attrs :height)))
|
||||||
(gsh/transform-rect transform))
|
(gsh/transform-rect transform))
|
||||||
(gsb/get-shape-filter-bounds shape))))
|
(gsb/get-shape-filter-bounds shape)))
|
||||||
|
|
||||||
(mf/defc svg-defs [{:keys [shape render-id]}]
|
(mf/defc svg-defs
|
||||||
(let [svg-defs (:svg-defs shape)
|
{::mf/wrap-props false}
|
||||||
|
[{:keys [shape render-id]}]
|
||||||
|
(let [defs (:svg-defs shape)
|
||||||
|
|
||||||
transform (mf/use-memo
|
transform (mf/with-memo [shape]
|
||||||
(mf/deps shape)
|
(if (= :svg-raw (:type shape))
|
||||||
#(if (= :svg-raw (:type shape))
|
|
||||||
(gmt/matrix)
|
(gmt/matrix)
|
||||||
(csvg/svg-transform-matrix shape)))
|
(csvg/svg-transform-matrix shape)))
|
||||||
|
|
||||||
|
@ -114,16 +115,17 @@
|
||||||
(gmt/multiply transform (:svg-transform shape))
|
(gmt/multiply transform (:svg-transform shape))
|
||||||
transform)
|
transform)
|
||||||
|
|
||||||
prefix-id
|
;; FIXME: naming
|
||||||
(fn [id]
|
prefix-id (mf/use-fn
|
||||||
(cond->> id
|
(mf/deps render-id defs)
|
||||||
(contains? svg-defs id) (str render-id "-")))]
|
(fn [id]
|
||||||
|
(cond->> id
|
||||||
|
(contains? defs id) (str render-id "-"))))]
|
||||||
|
|
||||||
(when (seq svg-defs)
|
(for [[key node] defs]
|
||||||
(for [[key svg-def] svg-defs]
|
[:& svg-node {:key (dm/str key)
|
||||||
[:& svg-node {:key (dm/str key)
|
:type (:type shape)
|
||||||
:type (:type shape)
|
:node node
|
||||||
:node svg-def
|
:prefix-id prefix-id
|
||||||
:prefix-id prefix-id
|
:transform transform
|
||||||
:transform transform
|
:bounds (get-svg-def-bounds node shape transform)}])))
|
||||||
:bounds (svg-def-bounds svg-def shape transform)}]))))
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue