0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-07 15:39:42 -05:00

🐛 Fix problem with thumbnail refresh

This commit is contained in:
alonso.torres 2022-04-27 15:20:47 +02:00
parent 609ce1c106
commit c3be87ed30
4 changed files with 19 additions and 17 deletions

View file

@ -117,6 +117,7 @@
thumb-renderer
[:g.frame-thumbnail
[:> frame/frame-thumbnail {:shape (cond-> shape
[:> frame/frame-thumbnail {:key (dm/str (:id shape))
:shape (cond-> shape
(some? thumbnail-data)
(assoc :thumbnail thumbnail-data))}]]]))))

View file

@ -38,15 +38,18 @@
(mf/use-layout-effect
(mf/deps transforms)
(fn []
(when (and (empty? @prev-modifiers) (d/not-empty? modifiers))
(utils/start-transform! node shapes))
(let [is-prev-val? (d/not-empty? @prev-modifiers)
is-cur-val? (d/not-empty? modifiers)]
(when (d/not-empty? modifiers)
(utils/update-transform! node shapes transforms modifiers))
(when (and (not is-prev-val?) is-cur-val?)
(utils/start-transform! node shapes))
(when (and (d/not-empty? @prev-modifiers) (empty? modifiers))
(utils/remove-transform! node @prev-shapes))
(when is-cur-val?
(utils/update-transform! node shapes transforms modifiers))
(reset! prev-modifiers modifiers)
(reset! prev-transforms transforms)
(reset! prev-shapes shapes)))))
(when (and is-prev-val? (not is-cur-val?))
(utils/remove-transform! node @prev-shapes))
(reset! prev-modifiers modifiers)
(reset! prev-transforms transforms)
(reset! prev-shapes shapes))))))

View file

@ -48,11 +48,10 @@
(mf/use-callback
(fn []
(let [canvas-node (mf/ref-val frame-canvas-ref)
img-node (mf/ref-val frame-image-ref)]
(ts/raf
#(let [thumb-data (draw-thumbnail-canvas canvas-node img-node)]
(st/emit! (dw/update-thumbnail id thumb-data))
(reset! image-url nil))))))
img-node (mf/ref-val frame-image-ref)
thumb-data (draw-thumbnail-canvas canvas-node img-node)]
(st/emit! (dw/update-thumbnail id thumb-data))
(reset! image-url nil))))
on-change
(mf/use-callback
@ -70,7 +69,6 @@
(dom/set-property! "height" height)
(dom/set-property! "fill" "none")
(obj/set! "innerHTML" frame-html))
img-src (-> svg-node dom/node->xml dom/svg->data-uri)]
(reset! image-url img-src)))))))

View file

@ -91,7 +91,7 @@
(cond
frame?
[thumb-node
(dom/query shape-node ".frame-background")
(dom/get-parent (dom/query shape-node ".frame-background"))
(dom/query shape-node ".frame-clip")]
;; For groups we don't want to transform the whole group but only