         )
       @plotview.moveCallbacks.push((e, x, y) =>
         if @dragging
-          offset = $(e.currentTarget).offset()
-          e.bokehX = e.pageX - offset.left
-          e.bokehY = e.pageY - offset.top
+          set_bokehXY(e)
           inner_range_horizontal = @plotview.view_state.get(
             'inner_range_horizontal')
           inner_range_vertical = @plotview.view_state.get(

          return
        if not @tool_active
          return
        offset = $(e.currentTarget).offset()
        e.bokehX = e.pageX - offset.left
        e.bokehY = e.pageY - offset.top

        if not @basepoint_set
          @dragging = true


define [], () ->

  set_bokehXY = (event) ->
    offset = $(event.currentTarget).offset()
    left = if offset? then offset.left else 0
    top = if offset? then offset.top else 0
    event.bokehX = event.pageX - left
    event.bokehY = event.pageY - top

  class TwoPointEventGenerator

