Skip to content

Commit bfd1a8f

Browse files
committed
enhance fill preview
1 parent dfa1ee2 commit bfd1a8f

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/renderer/tool/impl/misc/fill.cljs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,23 @@
2323
[db]
2424
(tool.handlers/set-cursor db "crosshair"))
2525

26-
(defmethod tool.hierarchy/on-pointer-up :fill
27-
[db e]
26+
(defn fill
27+
[db]
2828
(let [color (document.handlers/attr db :fill)
29-
el-id (-> e :element :id)]
30-
(-> (element.handlers/set-attr db el-id :fill color)
29+
el-id (-> db :clicked-element :id)]
30+
(-> db
31+
(dissoc :clicked-element)
32+
(element.handlers/set-attr el-id :fill color)
3133
(history.handlers/finalize #(t [::fill "Fill"])))))
3234

35+
(defmethod tool.hierarchy/on-pointer-up :fill
36+
[db _e]
37+
(fill db))
38+
39+
(defmethod tool.hierarchy/on-drag-end :fill
40+
[db _e]
41+
(fill db))
42+
3343
(defmethod tool.hierarchy/on-pointer-move :fill
3444
[db e]
3545
(let [color (document.handlers/attr db :fill)
@@ -39,5 +49,7 @@
3949
(element.handlers/set-attr (:id el) :fill color))))
4050

4151
(defmethod tool.hierarchy/on-pointer-down :fill
42-
[db _e]
43-
(history.handlers/reset-state db))
52+
[db e]
53+
(-> db
54+
(assoc :clicked-element (-> e :element))
55+
(history.handlers/reset-state)))

0 commit comments

Comments
 (0)