mirror of
https://github.com/penpot/penpot.git
synced 2025-06-10 13:01:40 +02:00
⚡ Add minor optimizations to rect shape
This commit is contained in:
parent
ad58c97cbd
commit
281251ff87
1 changed files with 13 additions and 9 deletions
|
@ -6,7 +6,9 @@
|
||||||
|
|
||||||
(ns app.main.ui.shapes.rect
|
(ns app.main.ui.shapes.rect
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.data.macros :as dm]
|
||||||
[app.common.geom.shapes :as gsh]
|
[app.common.geom.shapes :as gsh]
|
||||||
|
[app.main.ui.context :as muc]
|
||||||
[app.main.ui.shapes.attrs :as attrs]
|
[app.main.ui.shapes.attrs :as attrs]
|
||||||
[app.main.ui.shapes.custom-stroke :refer [shape-custom-strokes]]
|
[app.main.ui.shapes.custom-stroke :refer [shape-custom-strokes]]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
|
@ -16,16 +18,18 @@
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (unchecked-get props "shape")
|
(let [shape (unchecked-get props "shape")
|
||||||
{:keys [x y width height]} shape
|
|
||||||
transform (gsh/transform-str shape)
|
|
||||||
|
|
||||||
props (-> (attrs/extract-style-attrs shape)
|
x (dm/get-prop shape :x)
|
||||||
(obj/merge!
|
y (dm/get-prop shape :y)
|
||||||
#js {:x x
|
w (dm/get-prop shape :width)
|
||||||
:y y
|
h (dm/get-prop shape :height)
|
||||||
:transform transform
|
|
||||||
:width width
|
t (gsh/transform-str shape)
|
||||||
:height height}))
|
rid (mf/use-ctx muc/render-id)
|
||||||
|
|
||||||
|
props (mf/with-memo [shape rid]
|
||||||
|
(-> (attrs/extract-style-attrs shape rid)
|
||||||
|
(obj/merge! #js {:x x :y y :transform t :width w :height h})))
|
||||||
|
|
||||||
path? (some? (.-d props))]
|
path? (some? (.-d props))]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue