mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -05:00
🐛 Fix performance issue with focus mode
This commit is contained in:
parent
bb18a69394
commit
2ce766c49e
3 changed files with 16 additions and 6 deletions
|
@ -126,5 +126,8 @@
|
||||||
:ref on-frame-load
|
:ref on-frame-load
|
||||||
:opacity (when (:hidden shape) 0)}
|
:opacity (when (:hidden shape) 0)}
|
||||||
[:& ff/fontfaces-style {:fonts fonts}]
|
[:& 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]]]))))
|
thumbnail-renderer]]]))))
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
|
[app.main.data.workspace.thumbnails :as dwt]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
|
[app.main.store :as st]
|
||||||
[app.main.ui.hooks :as hooks]
|
[app.main.ui.hooks :as hooks]
|
||||||
[app.main.ui.shapes.frame :as frame]
|
[app.main.ui.shapes.frame :as frame]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
|
@ -83,7 +85,12 @@
|
||||||
img-node (mf/ref-val frame-image-ref)]
|
img-node (mf/ref-val frame-image-ref)]
|
||||||
(when (draw-thumbnail-canvas! canvas-node img-node)
|
(when (draw-thumbnail-canvas! canvas-node img-node)
|
||||||
(reset! image-url nil)
|
(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
|
generate-thumbnail
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
|
@ -183,7 +190,7 @@
|
||||||
:width fixed-width
|
:width fixed-width
|
||||||
:height fixed-height
|
:height fixed-height
|
||||||
;; DEBUG
|
;; DEBUG
|
||||||
:style {:filter (when (debug? :thumbnails) "sepia(1)")}}]]
|
:style {:filter (when (debug? :thumbnails) "invert(1)")}}]]
|
||||||
|
|
||||||
(when (some? @image-url)
|
(when (some? @image-url)
|
||||||
[:image {:ref frame-image-ref
|
[:image {:ref frame-image-ref
|
||||||
|
|
|
@ -71,8 +71,8 @@
|
||||||
focus (mf/deref refs/workspace-focus-selected)
|
focus (mf/deref refs/workspace-focus-selected)
|
||||||
|
|
||||||
objects-ref (mf/use-memo #(refs/workspace-page-objects-by-id page-id))
|
objects-ref (mf/use-memo #(refs/workspace-page-objects-by-id page-id))
|
||||||
base-objects (-> (mf/deref objects-ref)
|
objects (mf/deref objects-ref)
|
||||||
(ui-hooks/with-focus-objects focus))
|
base-objects (-> objects (ui-hooks/with-focus-objects focus))
|
||||||
|
|
||||||
modifiers (mf/deref refs/workspace-modifiers)
|
modifiers (mf/deref refs/workspace-modifiers)
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@
|
||||||
[:g {:pointer-events "none" :opacity 0}
|
[:g {:pointer-events "none" :opacity 0}
|
||||||
[:& stv/viewport-texts {:key (dm/str "texts-" page-id)
|
[:& stv/viewport-texts {:key (dm/str "texts-" page-id)
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:objects base-objects
|
:objects objects
|
||||||
:modifiers modifiers
|
:modifiers modifiers
|
||||||
:edition edition}]]]
|
:edition edition}]]]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue