     if (@ in @canvasGraph.marks.all) then @canvasGraph.marks.update(@) else @canvasGraph.marks.add(@)
     @dragging = false
     @moving = false
+    window.removeEventListener 'mousemove', @onMouseMove
+    window.removeEventListener 'mouseup', @onMouseUp
 
-  toCanvasXPoint: (e) -> e.pageX-@canvas.getBoundingClientRect().left - window.scrollX
+  toCanvasXPoint: (e) -> e.pageX - @canvas.getBoundingClientRect().left - window.scrollX
 
   pointerXInElement: (e) -> e.offsetX || e.clientX - e.target.offsetLeft + window.pageXOffset - @canvas.getBoundingClientRect().left
 

      @moving = true
      @pointerOffset = (@toCanvasXPoint(e) - @canvasXMin)

  onMouseUp: (e) ->
    e.preventDefault()
    for mark in @canvasGraph.marks.all
      mark.dragging = false

    else
      @element.style.cursor = "move"

  onMouseMove: (e) =>
    e.preventDefault()
    @draw(e) if @dragging
    @move(e) if @moving
    @updateCursor(e) if @hovering

  onMouseDown: (e) =>
    e.preventDefault()

    console.log "E from onmousedown", e
    @element.parentNode.appendChild(@element) #move to end of container for z index
    if (Math.abs @pointerXInElement(e) - (@canvasXMax-@canvasXMin)) < 10
      @startingPoint = @canvasXMin
