0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-05 11:31:35 -05:00

🐛 Fix shortcuts for zoom now take into account the mouse position

This commit is contained in:
alonso.torres 2023-03-10 15:28:35 +01:00
parent 468e61e1e0
commit 0d9695de1d
3 changed files with 21 additions and 14 deletions

View file

@ -28,6 +28,7 @@
- Fix problem with text editor in Safari
- Fix unlink library color when blur color picker input [#3026](https://github.com/penpot/penpot/issues/3026)
- Fix snap pixel when moving path points on high zoom [#2930](https://github.com/penpot/penpot/issues/2930)
- Fix shortcuts for zoom now take into account the mouse position [#2924](https://github.com/penpot/penpot/issues/2924)
### :arrow_up: Deps updates

View file

@ -440,12 +440,12 @@
:increase-zoom {:tooltip "+"
:command ["+" "="]
:subsections [:zoom-workspace]
:fn #(st/emit! (dw/increase-zoom nil))}
:fn #(st/emit! (dw/increase-zoom))}
:decrease-zoom {:tooltip "-"
:command ["-" "_"]
:subsections [:zoom-workspace]
:fn #(st/emit! (dw/decrease-zoom nil))}
:fn #(st/emit! (dw/decrease-zoom))}
:reset-zoom {:tooltip (ds/shift "0")
:command "shift+0"

View file

@ -28,20 +28,26 @@
(update :vbox merge (select-keys vbox' [:x :y :width :height])))))
(defn increase-zoom
[center]
(ptk/reify ::increase-zoom
ptk/UpdateEvent
(update [_ state]
(update state :workspace-local
#(impl-update-zoom % center (fn [z] (min (* z 1.3) 200)))))))
([]
(increase-zoom ::auto))
([center]
(ptk/reify ::increase-zoom
ptk/UpdateEvent
(update [_ state]
(let [center (if (= center ::auto) @ms/mouse-position center)]
(update state :workspace-local
#(impl-update-zoom % center (fn [z] (min (* z 1.3) 200)))))))))
(defn decrease-zoom
[center]
(ptk/reify ::decrease-zoom
ptk/UpdateEvent
(update [_ state]
(update state :workspace-local
#(impl-update-zoom % center (fn [z] (max (/ z 1.3) 0.01)))))))
([]
(decrease-zoom ::auto))
([center]
(ptk/reify ::decrease-zoom
ptk/UpdateEvent
(update [_ state]
(let [center (if (= center ::auto) @ms/mouse-position center)]
(update state :workspace-local
#(impl-update-zoom % center (fn [z] (max (/ z 1.3) 0.01)))))))))
(defn set-zoom
[center scale]