Improved performance when rendering paths

This commit is contained in:
alonso.torres 2022-06-23 13:24:03 +02:00
parent 0654741e28
commit 90532b760a

View file

@ -14,6 +14,12 @@
[app.main.ui.workspace.shapes.path.common :as pc] [app.main.ui.workspace.shapes.path.common :as pc]
[rumext.alpha :as mf])) [rumext.alpha :as mf]))
(defn apply-content-modifiers
[shape content-modifiers]
(let [shape (update shape :content upc/apply-content-modifiers content-modifiers)
[_ new-selrect] (helpers/content->points+selrect shape (:content shape))]
(assoc shape :selrect new-selrect)))
(mf/defc path-wrapper (mf/defc path-wrapper
{::mf/wrap-props false} {::mf/wrap-props false}
[props] [props]
@ -22,11 +28,13 @@
content-modifiers (mf/deref content-modifiers-ref) content-modifiers (mf/deref content-modifiers-ref)
editing-id (mf/deref refs/selected-edition) editing-id (mf/deref refs/selected-edition)
editing? (= editing-id (:id shape)) editing? (= editing-id (:id shape))
shape (update shape :content upc/apply-content-modifiers content-modifiers)
[_ new-selrect] shape
(helpers/content->points+selrect shape (:content shape)) (mf/use-memo
shape (assoc shape :selrect new-selrect)] (mf/deps shape content-modifiers)
#(cond-> shape
(some? content-modifiers)
(apply-content-modifiers content-modifiers)))]
[:> shape-container {:shape shape [:> shape-container {:shape shape
:pointer-events (when editing? "none")} :pointer-events (when editing? "none")}