   return [tx - p.left, ty - p.top]
 
 
-position = (e) ->
+position = (el, e) ->
   if e.offsetX?
     {left: e.offsetX, top: e.offsetY}
   else
-    p = e.target.getBoundingClientRect()
+    p = el.getBoundingClientRect()
     {
       left: e.clientX - p.left,
       top: e.clientY - p.top,

    down = true
    e.preventDefault()
    document.onselectstart = -> false # disable selection while dragging
    p = position(e)
    lc.begin(p.left, p.top)

  canvas.addEventListener 'mousemove', (e) =>
    e.preventDefault()
    p = position(e)
    lc.continue(p.left, p.top)

  canvas.addEventListener 'mouseup', (e) =>
    e.preventDefault()
    document.onselectstart = -> true # enable selection while dragging
    p = position(e)
    lc.end(p.left, p.top)

  canvas.addEventListener 'mouseenter', (e) =>
    p = position(e)
    if buttonIsDown(e)
      lc.begin(p.left, p.top)

  canvas.addEventListener 'mouseout', (e) =>
    p = position(e)
    lc.end(p.left, p.top)

  canvas.addEventListener 'touchstart', (e) ->


  canvas.addEventListener 'touchend', (e) ->
    e.preventDefault()
    lc.end(coordsForTouchEvent(canvas, e)...)

  canvas.addEventListener 'touchcancel', (e) ->
    e.preventDefault()
    lc.end(coordsForTouchEvent(canvas, e)...)

  if panWithKeyboard
