mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 21:51:39 +02:00
🐛 Fix Thumbnail blur on mouse movements
This commit is contained in:
parent
af519b3f89
commit
74612178d7
1 changed files with 20 additions and 11 deletions
|
@ -17,19 +17,28 @@
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
|
(def thumbnail-scale-factor 2)
|
||||||
|
|
||||||
(defn- draw-thumbnail-canvas
|
(defn- draw-thumbnail-canvas
|
||||||
[canvas-node img-node]
|
[canvas-node img-node]
|
||||||
(try
|
(time (try
|
||||||
(when (and (some? canvas-node) (some? img-node))
|
(when (and (some? canvas-node) (some? img-node))
|
||||||
(let [canvas-context (.getContext canvas-node "2d")
|
(let [canvas-context (.getContext canvas-node "2d")
|
||||||
canvas-width (.-width canvas-node)
|
canvas-width (.-width canvas-node)
|
||||||
canvas-height (.-height canvas-node)]
|
canvas-height (.-height canvas-node)]
|
||||||
(.clearRect canvas-context 0 0 canvas-width canvas-height)
|
|
||||||
(.drawImage canvas-context img-node 0 0 canvas-width canvas-height)
|
(set! (.-width canvas-node) (* thumbnail-scale-factor canvas-width))
|
||||||
(.toDataURL canvas-node "image/png")))
|
(set! (.-height canvas-node) (* thumbnail-scale-factor canvas-height))
|
||||||
(catch :default err
|
(.setTransform canvas-context thumbnail-scale-factor 0 0 thumbnail-scale-factor 0 0)
|
||||||
(.error js/console err)
|
(set! (.-imageSmoothingEnabled canvas-context) true)
|
||||||
nil)))
|
(set! (.-imageSmoothingQuality canvas-context) "high")
|
||||||
|
|
||||||
|
(.clearRect canvas-context 0 0 canvas-width canvas-height)
|
||||||
|
(.drawImage canvas-context img-node 0 0 canvas-width canvas-height)
|
||||||
|
(.toDataURL canvas-node "image/png" 1.0)))
|
||||||
|
(catch :default err
|
||||||
|
(.error js/console err)
|
||||||
|
nil))))
|
||||||
|
|
||||||
(defn use-render-thumbnail
|
(defn use-render-thumbnail
|
||||||
"Hook that will create the thumbnail thata"
|
"Hook that will create the thumbnail thata"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue