     @element = document.createElement('div')
     @element.className = "mark"
 
-    @element.style.left = e.layerX + "px"
+    @element.style.left = @elementXOffset(e) + "px"
     @element.style.position =  'absolute'
     @element.style.top = e.target.offsetTop + "px"
     @element.style.height = @canvas.height - 13 + 'px' # subtract border height


  toCanvasXPoint: (e) -> e.pageX-@canvas.getBoundingClientRect().left - window.scrollX


module?.exports = CanvasGraph: CanvasGraph, Marks: Marks, Mark: Mark

    @element.addEventListener 'mouseover', (e) => @hovering = true
    @element.addEventListener 'mouseout', (e) => @hovering = false
    @element.addEventListener 'mousedown', (e) => @onMouseDown(e)
    @element.addEventListener 'click', (e) => @canvasGraph.marks.remove(@) if @elementYOffset(e) < 15
    window.addEventListener 'mousemove', (e) => @onMouseMove(e)
    window.addEventListener 'mouseup', (e) => @onMouseUp(e)

