Merge pull request #2025 from penpot/alotor-fix-path-performance

 Improved performance when rendering paths
This commit is contained in:
Alejandro 2022-06-23 13:46:59 +02:00 committed by GitHub
commit 4549281b6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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")}