Skip to content

Commit

Permalink
rename zoom handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc committed Dec 19, 2024
1 parent ef646f7 commit b6d4419
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/renderer/frame/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
[persist]
(fn [db [_ zoom]]
(let [current-zoom (get-in db [:documents (:active-document db) :zoom])]
(h/zoom-by db (/ zoom current-zoom)))))
(h/zoom-in-place db (/ zoom current-zoom)))))

(rf/reg-event-db
::zoom-in
[persist]
(fn [db [_]]
(h/zoom-by db (/ 1 (:zoom-sensitivity db)))))
(h/zoom-in-place db (/ 1 (:zoom-sensitivity db)))))

(rf/reg-event-db
::zoom-out
[persist]
(fn [db [_]]
(h/zoom-by db (:zoom-sensitivity db))))
(h/zoom-in-place db (:zoom-sensitivity db))))

(rf/reg-event-db
::pan-to-element
Expand Down
12 changes: 6 additions & 6 deletions src/renderer/frame/handlers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
(->> (:document-tabs db)
(reduce #(pan-by %1 (mat/div [(:width offset) (:height offset)] 2) %2) db)))))

(m/=> zoom-in-place [:-> App number? Vec2 App])
(defn zoom-in-place
(m/=> zoom-at-position [:-> App number? Vec2 App])
(defn zoom-at-position
[db factor pos]
(let [active-document (:active-document db)
zoom (get-in db [:documents active-document :zoom])
Expand All @@ -70,15 +70,15 @@
(m/=> zoom-at-pointer [:-> App number? App])
(defn zoom-at-pointer
[db factor]
(zoom-in-place db factor (:adjusted-pointer-pos db)))
(zoom-at-position db factor (:adjusted-pointer-pos db)))

(m/=> zoom-by [:-> App number? App])
(defn zoom-by
(m/=> zoom-in-place [:-> App number? App])
(defn zoom-in-place
[db factor]
(let [{:keys [zoom pan]} (get-in db [:documents (:active-document db)])
{:keys [width height]} (:dom-rect db)
position (mat/add pan (mat/div [width height] 2 zoom))]
(zoom-in-place db factor position)))
(zoom-at-position db factor position)))

(m/=> pan-to-bounds [:-> App Bounds App])
(defn pan-to-bounds
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/tool/impl/base/zoom.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
zoom (min width-ratio height-ratio)]
(-> (h/dissoc-temp db)
(h/set-cursor (if (pointer/shift? e) "zoom-out" "zoom-in"))
(frame.h/zoom-by (if (pointer/shift? e)
(:zoom-sensitivity db)
(/ zoom current-zoom)))
(frame.h/zoom-in-place (if (pointer/shift? e)
(:zoom-sensitivity db)
(/ zoom current-zoom)))
(frame.h/pan-to-bounds [x y offset-x offset-y])
(snap.h/update-viewport-tree)
(h/add-fx [::app.fx/persist]))))
Expand Down

0 comments on commit b6d4419

Please sign in to comment.