🐛 Many bugfixes.

This commit is contained in:
Andrey Antukh 2020-02-19 19:20:13 +01:00
parent 86a55fd292
commit ff43df6822
10 changed files with 97 additions and 112 deletions

View file

@ -22,10 +22,13 @@
(declare rect-shape)
(mf/defc rect-wrapper
{:wrap [#(mf/wrap-memo % =)]}
[{:keys [shape] :as props}]
(let [selected (mf/deref refs/selected-shapes)
selected? (contains? selected (:id shape))
on-mouse-down #(common/on-mouse-down % shape selected)]
(let [selected-iref (mf/use-memo
{:fn #(refs/make-selected (:id shape))
:deps (mf/deps (:id shape))})
selected? (mf/deref selected-iref)
on-mouse-down #(common/on-mouse-down % shape)]
[:g.shape {:class (when selected? "selected")
:on-mouse-down on-mouse-down}
[:& rect-shape {:shape shape}]]))