     p.x = mouse.x
     p.y = mouse.y
 
-    p.matrixTransform(@transformationGroup.getCTM().inverse())
+    p.matrixTransform(svgElement.getCTM().inverse())
 
     transformationMatrix = svgElement.createSVGMatrix()
       .translate(p.x, p.y)


  panZoom : (position, zoomLevel) ->

    svgElement = $svg[0]

    if position

      mouse =
	x: position[0] - $svg.offset().left
	y: position[1] - $svg.offset().top

    else

      mouse =
	x: $svg.width() / 2
	y: $svg.height() / 2

    scale = zoomLevel / @oldZoomLevel



class PanZoomSVG

  constructor : (@$el) ->

    EventMixin.extend(this)

    @buffer = 0
    @mouseDown = false
    @oldZoomLevel = 1

    $el
      .on("mousedown", @mouseDownHandler)
      .on("mouseup", @mouseUpHandler)
      .on("mousemove", @mouseMoveHandler)
      .on("mousewheel", @mouseWheelHandler)

  mouseDownHandler : => @mouseDown = true; return
  mouseUpHandler : => @mouseDown = false; return
  mouseWheelHandler : (event) =>

    event.preventDefault()
    return if @mouseDown

    buffer = @buffer
    { wheelDelta, wheelDeltaX, wheelDeltaY, pageX, pageY } = event.originalEvent

    buffer += wheelDeltaY
    unless -BUFFER_THRESHOLD < buffer < BUFFER_THRESHOLD

      if wheelDeltaY < 0
	wheelDelta = Math.ceil(buffer / BUFFER_THRESHOLD)
      else
	wheelDelta = Math.floor(buffer / BUFFER_THRESHOLD)

      buffer = buffer % BUFFER_THRESHOLD

      @panZoom([ pageX, pageY ], wheelDelta)


  mouseMoveHandler : (event) =>
