mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
🐛 Normalize zoom levels in workspace and viewer
This commit is contained in:
parent
b4bf6b9235
commit
20baf02726
4 changed files with 42 additions and 56 deletions
|
@ -73,6 +73,7 @@
|
||||||
- Fix edit blur attributes for multiselection [Taiga #2625](https://tree.taiga.io/project/penpot/issue/2625)
|
- Fix edit blur attributes for multiselection [Taiga #2625](https://tree.taiga.io/project/penpot/issue/2625)
|
||||||
- Fix auto hide header in viewer full screen [Taiga #2632](https://tree.taiga.io/project/penpot/issue/2632)
|
- Fix auto hide header in viewer full screen [Taiga #2632](https://tree.taiga.io/project/penpot/issue/2632)
|
||||||
- Fix zoom in/out after fit or fill [Taiga #2630](https://tree.taiga.io/project/penpot/issue/2630)
|
- Fix zoom in/out after fit or fill [Taiga #2630](https://tree.taiga.io/project/penpot/issue/2630)
|
||||||
|
- Normalize zoom levels in workspace and viewer [Taiga #2631](https://tree.taiga.io/project/penpot/issue/2631)
|
||||||
|
|
||||||
### :arrow_up: Deps updates
|
### :arrow_up: Deps updates
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,3 @@
|
||||||
:grid-alignment true
|
:grid-alignment true
|
||||||
:background "var(--color-white)"})
|
:background "var(--color-white)"})
|
||||||
|
|
||||||
(def zoom-levels
|
|
||||||
[0.01 0.03 0.05 0.07 0.09 0.10 0.11 0.13 0.15 0.18
|
|
||||||
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.50 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.00 2.16 2.27 2.38 2.50 2.62 2.75 2.88 3.00])
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.types.interactions :as cti]
|
[app.common.types.interactions :as cti]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.constants :as c]
|
|
||||||
[app.main.data.comments :as dcm]
|
[app.main.data.comments :as dcm]
|
||||||
[app.main.data.fonts :as df]
|
[app.main.data.fonts :as df]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
|
@ -190,21 +189,15 @@
|
||||||
(ptk/reify ::increase-zoom
|
(ptk/reify ::increase-zoom
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [increase (fn [zoom]
|
(let [increase #(min (* % 1.3) 200)]
|
||||||
(d/seek #(> % zoom)
|
(update-in state [:viewer-local :zoom] (fnil increase 1))))))
|
||||||
c/zoom-levels
|
|
||||||
zoom))]
|
|
||||||
(update-in state [:viewer-local :zoom] increase)))))
|
|
||||||
|
|
||||||
(def decrease-zoom
|
(def decrease-zoom
|
||||||
(ptk/reify ::decrease-zoom
|
(ptk/reify ::decrease-zoom
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [decrease (fn [zoom]
|
(let [decrease #(max (/ % 1.3) 0.01)]
|
||||||
(d/seek #(< % zoom)
|
(update-in state [:viewer-local :zoom] (fnil decrease 1))))))
|
||||||
(reverse c/zoom-levels)
|
|
||||||
zoom))]
|
|
||||||
(update-in state [:viewer-local :zoom] decrease)))))
|
|
||||||
|
|
||||||
(def reset-zoom
|
(def reset-zoom
|
||||||
(ptk/reify ::reset-zoom
|
(ptk/reify ::reset-zoom
|
||||||
|
|
|
@ -413,6 +413,43 @@
|
||||||
;; Workspace State Manipulation
|
;; Workspace State Manipulation
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
;; --- Toggle layout flag
|
||||||
|
|
||||||
|
(defn toggle-layout-flags
|
||||||
|
[& flags]
|
||||||
|
(ptk/reify ::toggle-layout-flags
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(update state :workspace-layout
|
||||||
|
(fn [stored]
|
||||||
|
(reduce (fn [flags flag]
|
||||||
|
(if (contains? flags flag)
|
||||||
|
(disj flags flag)
|
||||||
|
(conj flags flag)))
|
||||||
|
stored
|
||||||
|
(d/concat-set flags)))))))
|
||||||
|
|
||||||
|
;; --- Set element options mode
|
||||||
|
|
||||||
|
(defn set-options-mode
|
||||||
|
[mode]
|
||||||
|
(us/assert ::options-mode mode)
|
||||||
|
(ptk/reify ::set-options-mode
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(assoc-in state [:workspace-local :options-mode] mode))))
|
||||||
|
|
||||||
|
;; --- Tooltip
|
||||||
|
|
||||||
|
(defn assign-cursor-tooltip
|
||||||
|
[content]
|
||||||
|
(ptk/reify ::assign-cursor-tooltip
|
||||||
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(if (string? content)
|
||||||
|
(assoc-in state [:workspace-local :tooltip] content)
|
||||||
|
(assoc-in state [:workspace-local :tooltip] nil)))))
|
||||||
|
|
||||||
;; --- Viewport Sizing
|
;; --- Viewport Sizing
|
||||||
|
|
||||||
(declare increase-zoom)
|
(declare increase-zoom)
|
||||||
|
@ -552,44 +589,6 @@
|
||||||
(-> state
|
(-> state
|
||||||
(update :workspace-local dissoc :zooming)))))
|
(update :workspace-local dissoc :zooming)))))
|
||||||
|
|
||||||
|
|
||||||
;; --- Toggle layout flag
|
|
||||||
|
|
||||||
(defn toggle-layout-flags
|
|
||||||
[& flags]
|
|
||||||
(ptk/reify ::toggle-layout-flags
|
|
||||||
ptk/UpdateEvent
|
|
||||||
(update [_ state]
|
|
||||||
(update state :workspace-layout
|
|
||||||
(fn [stored]
|
|
||||||
(reduce (fn [flags flag]
|
|
||||||
(if (contains? flags flag)
|
|
||||||
(disj flags flag)
|
|
||||||
(conj flags flag)))
|
|
||||||
stored
|
|
||||||
(d/concat-set flags)))))))
|
|
||||||
|
|
||||||
;; --- Set element options mode
|
|
||||||
|
|
||||||
(defn set-options-mode
|
|
||||||
[mode]
|
|
||||||
(us/assert ::options-mode mode)
|
|
||||||
(ptk/reify ::set-options-mode
|
|
||||||
ptk/UpdateEvent
|
|
||||||
(update [_ state]
|
|
||||||
(assoc-in state [:workspace-local :options-mode] mode))))
|
|
||||||
|
|
||||||
;; --- Tooltip
|
|
||||||
|
|
||||||
(defn assign-cursor-tooltip
|
|
||||||
[content]
|
|
||||||
(ptk/reify ::assign-cursor-tooltip
|
|
||||||
ptk/UpdateEvent
|
|
||||||
(update [_ state]
|
|
||||||
(if (string? content)
|
|
||||||
(assoc-in state [:workspace-local :tooltip] content)
|
|
||||||
(assoc-in state [:workspace-local :tooltip] nil)))))
|
|
||||||
|
|
||||||
;; --- Zoom Management
|
;; --- Zoom Management
|
||||||
|
|
||||||
(defn- impl-update-zoom
|
(defn- impl-update-zoom
|
||||||
|
|
Loading…
Reference in a new issue