@@ -1612,6 +1612,22 @@ describe "TextEditorComponent", ->
|
|||||||
expect(nextAnimationFrame).toBe noAnimationFrame
|
expect(nextAnimationFrame).toBe noAnimationFrame
|
||||||
expect(editor.getSelectedScreenRange()).toEqual [[2, 4], [6, 8]]
|
expect(editor.getSelectedScreenRange()).toEqual [[2, 4], [6, 8]]
|
||||||
|
|
||||||
|
describe "when the editor is destroyed while dragging", ->
|
||||||
|
it "cleans up the handlers for window.mouseup and window.mousemove", ->
|
||||||
|
linesNode.dispatchEvent(buildMouseEvent('mousedown', clientCoordinatesForScreenPosition([2, 4]), which: 1))
|
||||||
|
linesNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenPosition([6, 8]), which: 1))
|
||||||
|
nextAnimationFrame()
|
||||||
|
|
||||||
|
spyOn(window, 'removeEventListener').andCallThrough()
|
||||||
|
|
||||||
|
linesNode.dispatchEvent(buildMouseEvent('mousemove', clientCoordinatesForScreenPosition([6, 10]), which: 1))
|
||||||
|
editor.destroy()
|
||||||
|
nextAnimationFrame()
|
||||||
|
|
||||||
|
call.args.pop() for call in window.removeEventListener.calls
|
||||||
|
expect(window.removeEventListener).toHaveBeenCalledWith('mouseup')
|
||||||
|
expect(window.removeEventListener).toHaveBeenCalledWith('mousemove')
|
||||||
|
|
||||||
describe "when a line is folded", ->
|
describe "when a line is folded", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
editor.foldBufferRow 4
|
editor.foldBufferRow 4
|
||||||
|
|||||||
@@ -750,10 +750,12 @@ TextEditorComponent = React.createClass
|
|||||||
lastMousePosition = {}
|
lastMousePosition = {}
|
||||||
animationLoop = =>
|
animationLoop = =>
|
||||||
@requestAnimationFrame =>
|
@requestAnimationFrame =>
|
||||||
if dragging
|
if dragging and @isMounted()
|
||||||
screenPosition = @screenPositionForMouseEvent(lastMousePosition)
|
screenPosition = @screenPositionForMouseEvent(lastMousePosition)
|
||||||
dragHandler(screenPosition)
|
dragHandler(screenPosition)
|
||||||
animationLoop()
|
animationLoop()
|
||||||
|
else if not @isMounted()
|
||||||
|
stopDragging()
|
||||||
|
|
||||||
onMouseMove = (event) ->
|
onMouseMove = (event) ->
|
||||||
lastMousePosition.clientX = event.clientX
|
lastMousePosition.clientX = event.clientX
|
||||||
@@ -768,10 +770,13 @@ TextEditorComponent = React.createClass
|
|||||||
onMouseUp() if event.which is 0
|
onMouseUp() if event.which is 0
|
||||||
|
|
||||||
onMouseUp = ->
|
onMouseUp = ->
|
||||||
|
stopDragging()
|
||||||
|
editor.finalizeSelections()
|
||||||
|
|
||||||
|
stopDragging = ->
|
||||||
dragging = false
|
dragging = false
|
||||||
window.removeEventListener('mousemove', onMouseMove)
|
window.removeEventListener('mousemove', onMouseMove)
|
||||||
window.removeEventListener('mouseup', onMouseUp)
|
window.removeEventListener('mouseup', onMouseUp)
|
||||||
editor.finalizeSelections()
|
|
||||||
|
|
||||||
window.addEventListener('mousemove', onMouseMove)
|
window.addEventListener('mousemove', onMouseMove)
|
||||||
window.addEventListener('mouseup', onMouseUp)
|
window.addEventListener('mouseup', onMouseUp)
|
||||||
|
|||||||
Referência em uma Nova Issue
Bloquear um usuário