Add TextEditorPresenter::state.scrollingVertically
This is used by the view to defer measuring new lines until we stop scrolling.
Esse commit está contido em:
@@ -63,6 +63,20 @@ describe "TextEditorPresenter", ->
|
||||
expectStateUpdate presenter, -> presenter.setScrollTop(50)
|
||||
expect(presenter.state.scrollTop).toBe 50
|
||||
|
||||
describe ".scrollingVertically", ->
|
||||
it "is true for ::stoppedScrollingDelay milliseconds following a changes to ::scrollTop", ->
|
||||
presenter = new TextEditorPresenter(model: editor, scrollTop: 10, stoppedScrollingDelay: 200)
|
||||
expect(presenter.state.scrollingVertically).toBe false
|
||||
expectStateUpdate presenter, -> presenter.setScrollTop(0)
|
||||
expect(presenter.state.scrollingVertically).toBe true
|
||||
advanceClock(100)
|
||||
expect(presenter.state.scrollingVertically).toBe true
|
||||
presenter.setScrollTop(10)
|
||||
advanceClock(100)
|
||||
expect(presenter.state.scrollingVertically).toBe true
|
||||
expectStateUpdate presenter, -> advanceClock(100)
|
||||
expect(presenter.state.scrollingVertically).toBe false
|
||||
|
||||
describe ".content", ->
|
||||
describe ".scrollWidth", ->
|
||||
it "is initialized as the max of the clientWidth and the width of the longest line", ->
|
||||
|
||||
@@ -6,8 +6,13 @@ module.exports =
|
||||
class TextEditorPresenter
|
||||
toggleCursorBlinkHandle: null
|
||||
startBlinkingCursorsAfterDelay: null
|
||||
stoppedScrollingTimeoutId: null
|
||||
|
||||
constructor: (params) ->
|
||||
{@model, @clientHeight, @clientWidth, @scrollTop, @scrollLeft} = params
|
||||
{@lineHeight, @baseCharacterWidth, @lineOverdrawMargin, @backgroundColor} = params
|
||||
{@cursorBlinkPeriod, @cursorBlinkResumeDelay, @stoppedScrollingDelay} = params
|
||||
|
||||
constructor: ({@model, @clientHeight, @clientWidth, @scrollTop, @scrollLeft, @lineHeight, @baseCharacterWidth, @lineOverdrawMargin, @cursorBlinkPeriod, @cursorBlinkResumeDelay, @backgroundColor}) ->
|
||||
@disposables = new CompositeDisposable
|
||||
@emitter = new Emitter
|
||||
@charWidthsByScope = {}
|
||||
@@ -43,6 +48,7 @@ class TextEditorPresenter
|
||||
|
||||
buildState: ->
|
||||
@state =
|
||||
scrollingVertically: false
|
||||
content:
|
||||
blinkCursorsOff: false
|
||||
lines: {}
|
||||
@@ -321,12 +327,25 @@ class TextEditorPresenter
|
||||
getCursorBlinkResumeDelay: -> @cursorBlinkResumeDelay
|
||||
|
||||
setScrollTop: (@scrollTop) ->
|
||||
@didStartScrolling()
|
||||
@updateVerticalScrollState()
|
||||
@updateLinesState()
|
||||
@updateCursorsState()
|
||||
@updateHighlightsState()
|
||||
@updateLineNumbersState()
|
||||
|
||||
didStartScrolling: ->
|
||||
if @stoppedScrollingTimeoutId?
|
||||
clearTimeout(@stoppedScrollingTimeoutId)
|
||||
@stoppedScrollingTimeoutId = null
|
||||
@stoppedScrollingTimeoutId = setTimeout(@didStopScrolling.bind(this), @stoppedScrollingDelay)
|
||||
@state.scrollingVertically = true
|
||||
@emitter.emit 'did-update-state'
|
||||
|
||||
didStopScrolling: ->
|
||||
@state.scrollingVertically = false
|
||||
@emitter.emit 'did-update-state'
|
||||
|
||||
getScrollTop: -> @scrollTop
|
||||
|
||||
setScrollLeft: (@scrollLeft) ->
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário