🐛 Fine tune thumbnails

This commit is contained in:
alonso.torres 2022-05-13 13:16:36 +02:00
parent 4b0b7463c7
commit ea50622bf7
2 changed files with 13 additions and 12 deletions

View file

@ -17,7 +17,7 @@
[beicon.core :as rx]
[rumext.alpha :as mf]))
(def thumbnail-scale-factor 2)
;; (def thumbnail-scale-factor 2)
(defn- draw-thumbnail-canvas
[canvas-node img-node]
@ -27,11 +27,12 @@
canvas-width (.-width canvas-node)
canvas-height (.-height canvas-node)]
(set! (.-width canvas-node) (* thumbnail-scale-factor canvas-width))
(set! (.-height canvas-node) (* thumbnail-scale-factor canvas-height))
(.setTransform canvas-context thumbnail-scale-factor 0 0 thumbnail-scale-factor 0 0)
(set! (.-imageSmoothingEnabled canvas-context) true)
(set! (.-imageSmoothingQuality canvas-context) "high")
;; TODO: Expermient with different scale factors
;; (set! (.-width canvas-node) (* thumbnail-scale-factor canvas-width))
;; (set! (.-height canvas-node) (* thumbnail-scale-factor canvas-height))
;; (.setTransform canvas-context thumbnail-scale-factor 0 0 thumbnail-scale-factor 0 0)
;; (set! (.-imageSmoothingEnabled canvas-context) true)
;; (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)

View file

@ -242,19 +242,19 @@
;; Rules for active frame:
;; - If zoom < 25% displays thumbnail except when selecting a single frame or a child
;; - 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
;; - Check always that the active frames are inside the vbox
(let [is-active-frame?
(fn [id]
(or
;; Zoom > 150% shows every frame
(> zoom 1.5)
;; Zoom > 130% shows every frame
(> zoom 1.3)
;; Zoom >= 30% will show frames hovering
;; Zoom >= 25% will show frames hovering
(and
(>= zoom 0.3)
(>= zoom 0.25)
(or (= id hover-frame) (= id @last-hover-frame)))
;; Otherwise, if it's a selected frame
@ -272,7 +272,7 @@
all-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
;; this shortcuts outside the viewport?