mirror of
https://github.com/penpot/penpot.git
synced 2025-04-13 15:31:26 -05:00
Step based zoom (#12)
This commit is contained in:
parent
994d67e032
commit
cb3a099fef
1 changed files with 9 additions and 2 deletions
|
@ -18,6 +18,7 @@
|
|||
[uxbox.data.shapes :as uds]
|
||||
[uxbox.util.datetime :as dt]
|
||||
[uxbox.util.math :as mth]
|
||||
[uxbox.util.data :refer (index-of)]
|
||||
[uxbox.util.geom.point :as gpt]
|
||||
[uxbox.util.workers :as uw]))
|
||||
|
||||
|
@ -25,6 +26,12 @@
|
|||
|
||||
(declare initialize-alignment-index)
|
||||
|
||||
(defonce zoom-levels [0.20 0.21 0.22 0.23 0.24 0.25 0.27 0.28 0.30 0.32 0.34
|
||||
0.36 0.38 0.40 0.42 0.44 0.46 0.48 0.51 0.54 0.57 0.60
|
||||
0.63 0.66 0.69 0.73 0.77 0.81 0.85 0.90 0.95 1.00 1.05
|
||||
1.10 1.15 1.21 1.27 1.33 1.40 1.47 1.54 1.62 1.70 1.78
|
||||
1.87 1.96 2.06 2.16 2.27 2.38 2.50 2.62 2.75 2.88 3.00])
|
||||
|
||||
(defrecord InitializeWorkspace [project page]
|
||||
rs/UpdateEvent
|
||||
(-apply-update [_ state]
|
||||
|
@ -120,7 +127,7 @@
|
|||
(defrecord IncreaseZoom []
|
||||
rs/UpdateEvent
|
||||
(-apply-update [_ state]
|
||||
(let [increase #(min (mth/precision (* % 1.05) 2) 3)]
|
||||
(let [increase #(nth zoom-levels (+ (index-of zoom-levels %) 1) (last zoom-levels))]
|
||||
(update-in state [:workspace :zoom] (fnil increase 1)))))
|
||||
|
||||
(defn increase-zoom
|
||||
|
@ -132,7 +139,7 @@
|
|||
(defrecord DecreaseZoom []
|
||||
rs/UpdateEvent
|
||||
(-apply-update [_ state]
|
||||
(let [decrease #(max (mth/precision (* % 0.95) 2) 0.15)]
|
||||
(let [decrease #(nth zoom-levels (- (index-of zoom-levels %) 1) (first zoom-levels))]
|
||||
(update-in state [:workspace :zoom] (fnil decrease 1)))))
|
||||
|
||||
(defn decrease-zoom
|
||||
|
|
Loading…
Add table
Reference in a new issue