0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 07:50:43 -05:00

🐛 Fix performance issue with focus mode

This commit is contained in:
alonso.torres 2022-05-26 17:55:19 +02:00
parent bb18a69394
commit 2ce766c49e
3 changed files with 16 additions and 6 deletions

View file

@ -126,5 +126,8 @@
:ref on-frame-load
:opacity (when (:hidden shape) 0)}
[:& ff/fontfaces-style {:fonts fonts}]
[:g.frame-thumbnail-wrapper {:id (dm/str "thumbnail-container-" (:id shape))}
[:g.frame-thumbnail-wrapper
{:id (dm/str "thumbnail-container-" (:id shape))
;; Hide the thumbnail when not displaying
:opacity (when (and @rendered? (not thumbnail?)) 0)}
thumbnail-renderer]]]))))

View file

@ -9,7 +9,9 @@
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.math :as mth]
[app.main.data.workspace.thumbnails :as dwt]
[app.main.refs :as refs]
[app.main.store :as st]
[app.main.ui.hooks :as hooks]
[app.main.ui.shapes.frame :as frame]
[app.util.dom :as dom]
@ -83,7 +85,12 @@
img-node (mf/ref-val frame-image-ref)]
(when (draw-thumbnail-canvas! canvas-node img-node)
(reset! image-url nil)
(reset! render-frame? false))))))
(reset! render-frame? false))
;; If we don't have the thumbnail data saved (normaly the first load) we update the data
;; when available
(when (not @thumbnail-data-ref)
(st/emit! (dwt/update-thumbnail page-id id) ))))))
generate-thumbnail
(mf/use-callback
@ -183,7 +190,7 @@
:width fixed-width
:height fixed-height
;; DEBUG
:style {:filter (when (debug? :thumbnails) "sepia(1)")}}]]
:style {:filter (when (debug? :thumbnails) "invert(1)")}}]]
(when (some? @image-url)
[:image {:ref frame-image-ref

View file

@ -71,8 +71,8 @@
focus (mf/deref refs/workspace-focus-selected)
objects-ref (mf/use-memo #(refs/workspace-page-objects-by-id page-id))
base-objects (-> (mf/deref objects-ref)
(ui-hooks/with-focus-objects focus))
objects (mf/deref objects-ref)
base-objects (-> objects (ui-hooks/with-focus-objects focus))
modifiers (mf/deref refs/workspace-modifiers)
@ -245,7 +245,7 @@
[:g {:pointer-events "none" :opacity 0}
[:& stv/viewport-texts {:key (dm/str "texts-" page-id)
:page-id page-id
:objects base-objects
:objects objects
:modifiers modifiers
:edition edition}]]]