Skip to content

Commit 1ad49cb

Browse files
committed
build or update viewbox tree on init and on canvas focus
1 parent fab8c34 commit 1ad49cb

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/renderer/document/events.cljs

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
[renderer.history.handlers :as history.h]
1515
[renderer.notification.handlers :as notification.h]
1616
[renderer.notification.views :as notification.v]
17+
[renderer.snap.handlers :as snap.h]
1718
[renderer.utils.compatibility :as compatibility]
1819
[renderer.utils.dom :as dom]
1920
[renderer.utils.system :as system]
@@ -150,9 +151,9 @@
150151
::init
151152
[(rf/inject-cofx ::app.fx/guid)]
152153
(fn [{:keys [db guid]} [_]]
153-
{:db (cond-> db
154-
(not (:active-document db))
155-
(-> (create guid)
154+
{:db (if (:active-document db)
155+
(snap.h/rebuild-tree db)
156+
(-> (create db guid)
156157
(history.h/finalize "Init document")))}))
157158

158159
(rf/reg-event-fx

src/renderer/document/handlers.cljs

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@
8282
(-> db :window :focused)
8383
(not (get-in db (path db :focused))))
8484
(-> (frame.h/focus-bounds :original)
85-
(assoc-in (path db :focused) true))))
85+
(assoc-in (path db :focused) true)
86+
(snap.h/update-viewbox-tree))))
8687

8788
(m/=> search-by-path [:-> App string? [:maybe uuid?]])
8889
(defn search-by-path

src/renderer/frame/events.cljs

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@
66
[renderer.app.events]
77
[renderer.document.events :as-alias document.e]
88
[renderer.element.handlers :as element.h]
9-
[renderer.frame.handlers :as h]))
9+
[renderer.frame.handlers :as h]
10+
[renderer.snap.handlers :as snap.h]))
1011

1112
(rf/reg-event-db
1213
::resize
1314
[persist]
1415
(fn [db [_ dom-rect]]
1516
(-> db
1617
(h/recenter-to-dom-rect dom-rect)
17-
(assoc :dom-rect dom-rect))))
18+
(assoc :dom-rect dom-rect)
19+
(snap.h/update-viewbox-tree))))
1820

1921
(rf/reg-event-db
2022
::focus-selection
2123
[persist]
2224
(fn [db [_ focus-type]]
23-
(h/focus-bounds db focus-type)))
25+
(-> (h/focus-bounds db focus-type)
26+
(snap.h/update-viewbox-tree))))
2427

2528
(rf/reg-event-db
2629
::set-zoom

0 commit comments

Comments
 (0)