Skip to content

Commit 17a4bba

Browse files
committed
refactor
1 parent cfe6dd8 commit 17a4bba

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/renderer/snap/handlers.cljs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,18 @@
4242
(m/=> update-viewport-tree [:-> App App])
4343
(defn update-viewport-tree
4444
[db]
45-
(let [[x y width height] (frame.h/viewbox db)]
46-
(assoc db :viewbox-kdtree (->> [[x (+ x width)] [y (+ y height)]]
47-
(kdtree/interval-search (:kdtree db))
48-
(kdtree/build-tree)))))
45+
(let [[x y width height] (frame.h/viewbox db)
46+
boundaries [[x (+ x width)] [y (+ y height)]]]
47+
(assoc db :viewbox-kdtree (-> (:kdtree db)
48+
(kdtree/interval-search boundaries)
49+
(kdtree/build-tree)))))
4950

5051
(m/=> rebuild-tree [:-> App App])
5152
(defn rebuild-tree
5253
[db]
5354
(if (-> db :snap :active)
54-
(let [points (element.h/snapping-points db (tool.hierarchy/snapping-elements db))
55+
(let [elements (tool.hierarchy/snapping-elements db)
56+
points (element.h/snapping-points db elements)
5557
points (cond-> points
5658
(contains? (-> db :snap :options) :grid)
5759
(into (ruler.h/steps-intersections db)))]
@@ -71,17 +73,16 @@
7173

7274
(m/=> insert-to-tree [:-> App [:maybe [:set uuid?]] App])
7375
(defn insert-to-tree
74-
[db ids]
75-
(let [points (->> (element.h/entities db ids)
76-
(vals)
77-
(element.h/snapping-points db))]
76+
[db element-ids]
77+
(let [elements (vals (element.h/entities db element-ids))
78+
points (element.h/snapping-points db elements)]
7879
(update-tree db kdtree/insert points)))
7980

8081
(m/=> delete-from-tree [:-> App [:maybe [:set uuid?]] App])
8182
(defn delete-from-tree
82-
[db ids]
83-
(let [points (->> (vals (element.h/entities db ids))
84-
(element.h/snapping-points db))]
83+
[db element-ids]
84+
(let [elements (vals (element.h/entities db element-ids))
85+
points (element.h/snapping-points db elements)]
8586
(update-tree db kdtree/delete points)))
8687

8788
(m/=> nearest-delta [:-> App Vec2D])

0 commit comments

Comments
 (0)