mirror of
https://github.com/penpot/penpot.git
synced 2025-07-16 22:05:20 +02:00
⚡ Performance improvements
This commit is contained in:
parent
0204cdab83
commit
fa09fff2b5
12 changed files with 108 additions and 48 deletions
|
@ -247,7 +247,7 @@
|
|||
(gsh/calc-child-modifiers shape child modifiers ignore-constraints transformed-rect)]
|
||||
|
||||
(cond-> modif-tree
|
||||
(d/not-empty? (d/without-keys child-modifiers [:ignore-geometry?]))
|
||||
(d/not-empty? (dissoc child-modifiers :ignore-geometry?))
|
||||
(set-modifiers-recursive objects
|
||||
child
|
||||
child-modifiers
|
||||
|
|
|
@ -46,17 +46,10 @@
|
|||
(rx/subs #(reset! buffer (vec %))))
|
||||
buffer))
|
||||
|
||||
(defn emit!
|
||||
([] nil)
|
||||
([event]
|
||||
(ptk/emit! state event)
|
||||
nil)
|
||||
([event & events]
|
||||
(apply ptk/emit! state (cons event events))
|
||||
nil))
|
||||
(def emit! (partial ptk/emit! state))
|
||||
|
||||
(defn emitf
|
||||
[& events]
|
||||
#(apply ptk/emit! state events))
|
||||
#(ptk/emit! state events))
|
||||
|
||||
|
||||
|
|
|
@ -77,13 +77,13 @@
|
|||
:key (:id item)}]))]))
|
||||
|
||||
(mf/defc shape-wrapper
|
||||
{::mf/wrap [#(mf/memo' % (mf/check-props ["shape" "frame"]))]
|
||||
{::mf/wrap [#(mf/memo' % (mf/check-props ["shape"]))]
|
||||
::mf/wrap-props false}
|
||||
[props]
|
||||
(let [shape (obj/get props "shape")
|
||||
frame (obj/get props "frame")
|
||||
shape (-> (geom/transform-shape shape {:round-coords? false})
|
||||
(geom/translate-to-frame frame))
|
||||
shape (geom/translate-to-frame shape frame)
|
||||
|
||||
opts #js {:shape shape
|
||||
:frame frame}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
(ns app.main.ui.workspace.shapes.frame
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.pages :as cp]
|
||||
[app.main.ui.hooks :as hooks]
|
||||
|
@ -101,8 +102,7 @@
|
|||
objects (unchecked-get props "objects")
|
||||
thumbnail? (unchecked-get props "thumbnail?")
|
||||
|
||||
shape (gsh/transform-shape shape)
|
||||
children (-> (mapv #(get objects %) (:shapes shape))
|
||||
children (-> (mapv (d/getf objects) (:shapes shape))
|
||||
(hooks/use-equal-memo))
|
||||
|
||||
all-children (-> (cp/get-children-objects (:id shape) objects)
|
||||
|
|
|
@ -308,6 +308,7 @@
|
|||
:bool-type]))
|
||||
|
||||
(defn- strip-objects
|
||||
"Remove unnecesary data from objects map"
|
||||
[objects]
|
||||
(persistent!
|
||||
(->> objects
|
||||
|
@ -320,8 +321,11 @@
|
|||
{::mf/wrap-props false
|
||||
::mf/wrap [mf/memo #(mf/throttle % 200)]}
|
||||
[props]
|
||||
(let [objects (obj/get props "objects")
|
||||
objects (strip-objects objects)]
|
||||
(let [objects (-> (obj/get props "objects")
|
||||
(hooks/use-equal-memo))
|
||||
objects (mf/use-memo
|
||||
(mf/deps objects)
|
||||
#(strip-objects objects))]
|
||||
[:& layers-tree {:objects objects}]))
|
||||
|
||||
;; --- Layers Toolbox
|
||||
|
|
|
@ -61,11 +61,11 @@
|
|||
;; DEREFS
|
||||
drawing (mf/deref refs/workspace-drawing)
|
||||
options (mf/deref refs/workspace-page-options)
|
||||
objects (mf/deref refs/workspace-page-objects)
|
||||
base-objects (mf/deref refs/workspace-page-objects)
|
||||
object-modifiers (mf/deref refs/workspace-modifiers)
|
||||
objects (mf/use-memo
|
||||
(mf/deps objects object-modifiers)
|
||||
#(gsh/merge-modifiers objects object-modifiers))
|
||||
(mf/deps base-objects object-modifiers)
|
||||
#(gsh/merge-modifiers base-objects object-modifiers))
|
||||
background (get options :background clr/canvas)
|
||||
|
||||
;; STATE
|
||||
|
@ -163,7 +163,7 @@
|
|||
[:div.viewport
|
||||
[:div.viewport-overlays
|
||||
|
||||
[:& wtr/frame-renderer {:objects objects
|
||||
[:& wtr/frame-renderer {:objects base-objects
|
||||
:background background}]
|
||||
|
||||
(when show-comments?
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
[:g.draw-area
|
||||
[:g {:style {:pointer-events "none"}}
|
||||
[:& shapes/shape-wrapper {:shape shape}]]
|
||||
[:& shapes/shape-wrapper {:shape (gsh/transform-shape shape)}]]
|
||||
|
||||
(case tool
|
||||
:path [:& path-editor {:shape shape :zoom zoom}]
|
||||
|
|
|
@ -6,13 +6,14 @@
|
|||
|
||||
(ns app.main.ui.workspace.viewport.pixel-overlay
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.workspace.colors :as dwc]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.cursors :as cur]
|
||||
[app.main.ui.workspace.shapes :refer [shape-wrapper frame-wrapper]]
|
||||
[app.main.ui.workspace.shapes :as shapes]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.keyboard :as kbd]
|
||||
[app.util.object :as obj]
|
||||
|
@ -36,16 +37,16 @@
|
|||
(let [data (mf/deref refs/workspace-page)
|
||||
objects (:objects data)
|
||||
root (get objects uuid/zero)
|
||||
shapes (->> (:shapes root) (map #(get objects %)))]
|
||||
[:*
|
||||
[:g.shapes
|
||||
(for [item shapes]
|
||||
(if (= (:type item) :frame)
|
||||
[:& frame-wrapper {:shape item
|
||||
:key (:id item)
|
||||
:objects objects}]
|
||||
[:& shape-wrapper {:shape item
|
||||
:key (:id item)}]))]]))
|
||||
shapes (->> (:shapes root)
|
||||
(map (d/getf objects)))]
|
||||
[:g.shapes
|
||||
(for [item shapes]
|
||||
(if (= (:type item) :frame)
|
||||
[:& shapes/frame-wrapper {:shape item
|
||||
:key (:id item)
|
||||
:objects objects}]
|
||||
[:& shapes/shape-wrapper {:shape item
|
||||
:key (:id item)}]))]))
|
||||
|
||||
(mf/defc pixel-overlay
|
||||
{::mf/wrap-props false}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue