             :onMouseDown (fn [e]
                            (.preventDefault e)
                            (om/transact! data [:actions] (partial -start line-tool))
-                           (om/set-state! owner :drawing? true))
+                           (om/update! data [:drawing?] true))
             :onMouseUp (fn [_]
                          (let [idx (dec (count (:actions @data)))]
                            (om/transact! data [:actions idx]
                                          (partial -end line-tool) :add-to-undo)
-                           (om/set-state! owner :drawing? false)))
+                           (om/update! data [:drawing?] false)))
             :onMouseMove (fn [e]
-                           (when drawing?
+                           (when (:drawing? @data)
                              (let [dom (om/get-node owner)
                                    idx (dec (count (:actions @data)))
                                    x (- (.-pageX e) (.-offsetLeft dom))


(swap! app-state update-in [:tools] assoc :lineWidth 3)

)


(defn canvas [data owner]
  (reify
    om/IDidMount
    (did-mount [_]
      (repaint (.getContext (om/get-node owner) "2d")
