Handle selection dragging when cursor goes off-screen

This commit is contained in:
Nathan Sobo
2012-11-26 16:59:43 -07:00
parent bf9a7cc9a1
commit d47a82f585
2 changed files with 30 additions and 4 deletions

View File

@@ -358,10 +358,18 @@ class Editor extends View
@gutter.addClass('drop-shadow')
selectOnMousemoveUntilMouseup: ->
moveHandler = (e) => @selectToScreenPosition(@screenPositionFromMouseEvent(e))
@on 'mousemove', moveHandler
lastMoveEvent = null
moveHandler = (event = lastMoveEvent) =>
if event
@selectToScreenPosition(@screenPositionFromMouseEvent(event))
lastMoveEvent = event
$(document).on 'mousemove', moveHandler
interval = setInterval(moveHandler, 20)
$(document).one 'mouseup', =>
@off 'mousemove', moveHandler
clearInterval(interval)
$(document).off 'mousemove', moveHandler
reverse = @activeEditSession.getLastSelection().isReversed()
@activeEditSession.mergeIntersectingSelections({reverse})
@activeEditSession.finalizeSelections()