mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-22 00:19:24 +03:00
Scroll editor using css 'top' property instead of scrollTop
This commit is contained in:
parent
9a5c252c85
commit
e2bd646e0f
@ -292,6 +292,25 @@ describe "Editor", ->
|
||||
editor.loadNextEditSession()
|
||||
expect(editor.buffer.path).toBe "2"
|
||||
|
||||
it "restores scroll postion of edit session", ->
|
||||
editor.attachToDom(heightInLines: 12)
|
||||
buffer1 = editor.buffer
|
||||
firstScrollTop = editor.scrollView.scrollTop()
|
||||
|
||||
buffer2 = new Buffer(require.resolve('fixtures/two-hundred.txt'))
|
||||
editor.setBuffer(buffer2)
|
||||
editor.moveCursorToBottom()
|
||||
secondScrollTop = editor.scrollView.scrollTop()
|
||||
|
||||
expect(firstScrollTop).not.toEqual secondScrollTop
|
||||
editor.loadNextEditSession()
|
||||
expect(editor.buffer.path).toBe buffer1.path
|
||||
expect(editor.scrollView.scrollTop()).toBe firstScrollTop
|
||||
|
||||
editor.loadNextEditSession()
|
||||
expect(editor.buffer.path).toBe buffer2.path
|
||||
expect(editor.scrollView.scrollTop()).toBe secondScrollTop
|
||||
|
||||
describe ".loadPreviousEditSession()", ->
|
||||
it "loads the next editor state and wraps to beginning when end is reached", ->
|
||||
buffer0 = new Buffer("0")
|
||||
|
@ -285,7 +285,7 @@ class Editor extends View
|
||||
scrollTop: (scrollTop, options) ->
|
||||
return @cachedScrollTop or 0 unless scrollTop?
|
||||
|
||||
maxScrollTop = @scrollView.prop('scrollHeight') - @scrollView.height()
|
||||
maxScrollTop = @verticalScrollbar.prop('scrollHeight') - @verticalScrollbar.height()
|
||||
scrollTop = Math.floor(Math.min(maxScrollTop, Math.max(0, scrollTop)))
|
||||
|
||||
return if scrollTop == @cachedScrollTop
|
||||
@ -293,7 +293,7 @@ class Editor extends View
|
||||
|
||||
@updateRenderedLines() if @attached
|
||||
|
||||
@scrollView.scrollTop(scrollTop)
|
||||
@renderedLines.css('top', -scrollTop)
|
||||
@gutter.scrollTop(scrollTop)
|
||||
if options?.adjustVerticalScrollbar ? true
|
||||
@verticalScrollbar.scrollTop(scrollTop)
|
||||
|
Loading…
Reference in New Issue
Block a user