mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Oops. Fix tree-view auto-scrolling and specs after breaking them.
This commit is contained in:
@@ -12,7 +12,7 @@ module.exports =
|
||||
class TreeView extends ScrollView
|
||||
@content: (rootView) ->
|
||||
@div class: 'tree-view-resizer', =>
|
||||
@div class: 'tree-view-scroller', =>
|
||||
@div class: 'tree-view-scroller', outlet: 'scroller', =>
|
||||
@ol class: 'list-unstyled tree-view tool-panel', tabindex: -1, outlet: 'treeViewList'
|
||||
@div class: 'tree-view-resize-handle', outlet: 'resizeHandle'
|
||||
|
||||
@@ -309,33 +309,30 @@ class TreeView extends ScrollView
|
||||
@treeViewList.find('.selected').removeClass('selected')
|
||||
|
||||
scrollTop: (top) ->
|
||||
if top
|
||||
@treeViewList.scrollTop(top)
|
||||
if top?
|
||||
@scroller.scrollTop(top)
|
||||
else
|
||||
@treeViewList.scrollTop()
|
||||
@scroller.scrollTop()
|
||||
|
||||
scrollBottom: (bottom) ->
|
||||
if bottom
|
||||
@treeViewList.scrollBottom(bottom)
|
||||
if bottom?
|
||||
@scroller.scrollBottom(bottom)
|
||||
else
|
||||
@treeViewList.scrollBottom()
|
||||
@scroller.scrollBottom()
|
||||
|
||||
scrollToEntry: (entry) ->
|
||||
displayElement = if entry instanceof DirectoryView then entry.header else entry
|
||||
top = @scrollTop() + displayElement.position().top
|
||||
top = displayElement.position().top
|
||||
bottom = top + displayElement.outerHeight()
|
||||
if bottom > @scrollBottom()
|
||||
@treeViewList.scrollBottom(bottom)
|
||||
@scrollBottom(bottom)
|
||||
if top < @scrollTop()
|
||||
@treeViewList.scrollTop(top)
|
||||
@scrollTop(top)
|
||||
|
||||
scrollToBottom: ->
|
||||
super()
|
||||
|
||||
@selectEntry(@root.find('.entry:last')) if @root
|
||||
@scrollToEntry(@root.find('.entry:last')) if @root
|
||||
|
||||
scrollToTop: ->
|
||||
super()
|
||||
@selectEntry(@root) if @root
|
||||
@treeViewList.scrollTop(0)
|
||||
@scrollTop(0)
|
||||
|
||||
@@ -428,7 +428,7 @@ describe "TreeView", ->
|
||||
treeView.height(100)
|
||||
treeView.attachToDom()
|
||||
$(element).view().expand() for element in treeView.find('.directory')
|
||||
expect(treeView.treeViewList.prop('scrollHeight')).toBeGreaterThan treeView.treeViewList.outerHeight()
|
||||
expect(treeView.treeViewList.outerHeight()).toBeGreaterThan treeView.scroller.outerHeight()
|
||||
|
||||
expect(treeView.scrollTop()).toBe 0
|
||||
|
||||
@@ -452,7 +452,7 @@ describe "TreeView", ->
|
||||
treeView.height(100)
|
||||
treeView.attachToDom()
|
||||
$(element).view().expand() for element in treeView.find('.directory')
|
||||
expect(treeView.treeViewList.prop('scrollHeight')).toBeGreaterThan treeView.treeViewList.outerHeight()
|
||||
expect(treeView.treeViewList.outerHeight()).toBeGreaterThan treeView.scroller.outerHeight()
|
||||
|
||||
expect(treeView.scrollTop()).toBe 0
|
||||
treeView.trigger 'core:move-to-bottom'
|
||||
@@ -468,7 +468,7 @@ describe "TreeView", ->
|
||||
treeView.height(5)
|
||||
treeView.attachToDom()
|
||||
$(element).view().expand() for element in treeView.find('.directory')
|
||||
expect(treeView.treeViewList.prop('scrollHeight')).toBeGreaterThan treeView.treeViewList.outerHeight()
|
||||
expect(treeView.treeViewList.outerHeight()).toBeGreaterThan treeView.scroller.outerHeight()
|
||||
|
||||
expect(treeView.scrollTop()).toBe 0
|
||||
treeView.scrollToBottom()
|
||||
@@ -483,7 +483,7 @@ describe "TreeView", ->
|
||||
treeView.height(5)
|
||||
treeView.attachToDom()
|
||||
$(element).view().expand() for element in treeView.find('.directory')
|
||||
expect(treeView.treeViewList.prop('scrollHeight')).toBeGreaterThan treeView.treeViewList.outerHeight()
|
||||
expect(treeView.treeViewList.outerHeight()).toBeGreaterThan treeView.scroller.outerHeight()
|
||||
|
||||
expect(treeView.scrollTop()).toBe 0
|
||||
treeView.trigger 'core:page-down'
|
||||
@@ -494,14 +494,16 @@ describe "TreeView", ->
|
||||
treeView.height(100)
|
||||
treeView.attachToDom()
|
||||
$(element).view().expand() for element in treeView.find('.directory')
|
||||
expect(treeView.treeViewList.prop('scrollHeight')).toBeGreaterThan treeView.treeViewList.outerHeight()
|
||||
expect(treeView.treeViewList.outerHeight()).toBeGreaterThan treeView.scroller.outerHeight()
|
||||
|
||||
treeView.moveDown()
|
||||
expect(treeView.scrollTop()).toBe 0
|
||||
|
||||
entryCount = treeView.find(".entry").length
|
||||
entryHeight = treeView.find('.file').height()
|
||||
|
||||
_.times entryCount, -> treeView.moveDown()
|
||||
expect(treeView.scrollBottom()).toBe treeView.root.outerHeight()
|
||||
expect(treeView.scrollBottom()).toBeGreaterThan (entryCount * entryHeight) - 1
|
||||
|
||||
_.times entryCount, -> treeView.moveUp()
|
||||
expect(treeView.scrollTop()).toBe 0
|
||||
|
||||
Reference in New Issue
Block a user