mirror of
https://github.com/penpot/penpot.git
synced 2025-05-11 17:46:38 +02:00
🐛 Fine tune thumbnails
This commit is contained in:
parent
4b0b7463c7
commit
ea50622bf7
2 changed files with 13 additions and 12 deletions
|
@ -17,7 +17,7 @@
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(def thumbnail-scale-factor 2)
|
;; (def thumbnail-scale-factor 2)
|
||||||
|
|
||||||
(defn- draw-thumbnail-canvas
|
(defn- draw-thumbnail-canvas
|
||||||
[canvas-node img-node]
|
[canvas-node img-node]
|
||||||
|
@ -27,11 +27,12 @@
|
||||||
canvas-width (.-width canvas-node)
|
canvas-width (.-width canvas-node)
|
||||||
canvas-height (.-height canvas-node)]
|
canvas-height (.-height canvas-node)]
|
||||||
|
|
||||||
(set! (.-width canvas-node) (* thumbnail-scale-factor canvas-width))
|
;; TODO: Expermient with different scale factors
|
||||||
(set! (.-height canvas-node) (* thumbnail-scale-factor canvas-height))
|
;; (set! (.-width canvas-node) (* thumbnail-scale-factor canvas-width))
|
||||||
(.setTransform canvas-context thumbnail-scale-factor 0 0 thumbnail-scale-factor 0 0)
|
;; (set! (.-height canvas-node) (* thumbnail-scale-factor canvas-height))
|
||||||
(set! (.-imageSmoothingEnabled canvas-context) true)
|
;; (.setTransform canvas-context thumbnail-scale-factor 0 0 thumbnail-scale-factor 0 0)
|
||||||
(set! (.-imageSmoothingQuality canvas-context) "high")
|
;; (set! (.-imageSmoothingEnabled canvas-context) true)
|
||||||
|
;; (set! (.-imageSmoothingQuality canvas-context) "high")
|
||||||
|
|
||||||
(.clearRect canvas-context 0 0 canvas-width canvas-height)
|
(.clearRect canvas-context 0 0 canvas-width canvas-height)
|
||||||
(.drawImage canvas-context img-node 0 0 canvas-width canvas-height)
|
(.drawImage canvas-context img-node 0 0 canvas-width canvas-height)
|
||||||
|
|
|
@ -242,19 +242,19 @@
|
||||||
;; Rules for active frame:
|
;; Rules for active frame:
|
||||||
;; - If zoom < 25% displays thumbnail except when selecting a single frame or a child
|
;; - If zoom < 25% displays thumbnail except when selecting a single frame or a child
|
||||||
;; - We always active the current hovering frame for zoom > 25%
|
;; - We always active the current hovering frame for zoom > 25%
|
||||||
;; - When zoom > 150% we activate the frames that are inside the vbox
|
;; - When zoom > 130% we activate the frames that are inside the vbox
|
||||||
;; - If no hovering over any frames we keep the previous active one
|
;; - If no hovering over any frames we keep the previous active one
|
||||||
;; - Check always that the active frames are inside the vbox
|
;; - Check always that the active frames are inside the vbox
|
||||||
|
|
||||||
(let [is-active-frame?
|
(let [is-active-frame?
|
||||||
(fn [id]
|
(fn [id]
|
||||||
(or
|
(or
|
||||||
;; Zoom > 150% shows every frame
|
;; Zoom > 130% shows every frame
|
||||||
(> zoom 1.5)
|
(> zoom 1.3)
|
||||||
|
|
||||||
;; Zoom >= 30% will show frames hovering
|
;; Zoom >= 25% will show frames hovering
|
||||||
(and
|
(and
|
||||||
(>= zoom 0.3)
|
(>= zoom 0.25)
|
||||||
(or (= id hover-frame) (= id @last-hover-frame)))
|
(or (= id hover-frame) (= id @last-hover-frame)))
|
||||||
|
|
||||||
;; Otherwise, if it's a selected frame
|
;; Otherwise, if it's a selected frame
|
||||||
|
@ -272,7 +272,7 @@
|
||||||
all-frames)]
|
all-frames)]
|
||||||
|
|
||||||
(when (not= @active-frames new-active-frames)
|
(when (not= @active-frames new-active-frames)
|
||||||
(reset! active-frames new-active-frames)))))))
|
(reset! active-frames #{} #_new-active-frames)))))))
|
||||||
|
|
||||||
;; NOTE: this is executed on each page change, maybe we need to move
|
;; NOTE: this is executed on each page change, maybe we need to move
|
||||||
;; this shortcuts outside the viewport?
|
;; this shortcuts outside the viewport?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue