mirror of
https://github.com/atom/atom.git
synced 2026-02-18 10:31:54 -05:00
Fixing the scrolling errors created by adding a wrapper
This commit is contained in:
@@ -74,15 +74,15 @@ class TreeView extends ScrollView
|
||||
@selectEntry(@root) if @root
|
||||
|
||||
afterAttach: (onDom) ->
|
||||
@focus() if @focusAfterAttach
|
||||
@scrollTop(@scrollTopAfterAttach) if @scrollTopAfterAttach > 0
|
||||
@treeViewList.focus() if @focusAfterAttach
|
||||
@treeViewList.scrollTop(@scrollTopAfterAttach) if @scrollTopAfterAttach > 0
|
||||
|
||||
serialize: ->
|
||||
directoryExpansionStates: @root?.serializeEntryExpansionStates()
|
||||
selectedPath: @selectedEntry()?.getPath()
|
||||
hasFocus: @hasFocus()
|
||||
attached: @hasParent()
|
||||
scrollTop: @scrollTop()
|
||||
scrollTop: @treeViewList.scrollTop()
|
||||
width: @width()
|
||||
|
||||
deactivate: ->
|
||||
@@ -93,14 +93,14 @@ class TreeView extends ScrollView
|
||||
@detach()
|
||||
else
|
||||
if @hasParent()
|
||||
@focus()
|
||||
@treeViewList.focus()
|
||||
else
|
||||
@attach()
|
||||
|
||||
attach: ->
|
||||
return unless rootView.project.getPath()
|
||||
@rootView.horizontal.prepend(this)
|
||||
@focus()
|
||||
@treeViewList.focus()
|
||||
|
||||
detach: ->
|
||||
@scrollTopAfterAttach = @scrollTop()
|
||||
@@ -108,7 +108,7 @@ class TreeView extends ScrollView
|
||||
@rootView.focus()
|
||||
|
||||
hasFocus: ->
|
||||
@is(':focus')
|
||||
@treeViewList.is(':focus')
|
||||
|
||||
entryClicked: (e) ->
|
||||
entry = $(e.currentTarget).view()
|
||||
@@ -174,7 +174,7 @@ class TreeView extends ScrollView
|
||||
else
|
||||
bestMatchEntry
|
||||
|
||||
@find(".entry").toArray().reduce(fn, @root)
|
||||
@treeViewList.find(".entry").toArray().reduce(fn, @root)
|
||||
|
||||
selectEntryForPath: (path) ->
|
||||
@selectEntry(@entryForPath(path))
|
||||
@@ -295,32 +295,34 @@ class TreeView extends ScrollView
|
||||
@rootView.append(dialog)
|
||||
|
||||
selectedEntry: ->
|
||||
@find('.selected')?.view()
|
||||
@treeViewList.find('.selected')?.view()
|
||||
|
||||
selectEntry: (entry) ->
|
||||
return false unless entry.get(0)
|
||||
entry = entry.view() unless entry instanceof View
|
||||
@selectedPath = entry.getPath()
|
||||
@find('.selected').removeClass('selected')
|
||||
@treeViewList.find('.selected').removeClass('selected')
|
||||
entry.addClass('selected')
|
||||
|
||||
scrollToEntry: (entry) ->
|
||||
displayElement = if entry instanceof DirectoryView then entry.header else entry
|
||||
|
||||
top = @scrollTop() + displayElement.position().top
|
||||
top = @treeViewList.scrollTop() + displayElement.position().top
|
||||
bottom = top + displayElement.outerHeight()
|
||||
|
||||
if bottom > @scrollBottom()
|
||||
@scrollBottom(bottom)
|
||||
if top < @scrollTop()
|
||||
@scrollTop(top)
|
||||
if bottom > @treeViewList.scrollBottom()
|
||||
@treeViewList.scrollBottom(bottom)
|
||||
if top < @treeViewList.scrollTop()
|
||||
@treeViewList.scrollTop(top)
|
||||
|
||||
scrollToBottom: ->
|
||||
super()
|
||||
|
||||
@selectEntry(@root.find('.entry:last')) if @root
|
||||
@scrollToEntry(@root.find('.entry:last')) if @root
|
||||
|
||||
scrollToTop: ->
|
||||
super()
|
||||
|
||||
@selectEntry(@root) if @root
|
||||
@scrollToEntry(@root) if @root
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
}
|
||||
|
||||
.tree-view {
|
||||
position: relative;
|
||||
cursor: default;
|
||||
-webkit-user-select: none;
|
||||
overflow: auto;
|
||||
@@ -29,13 +30,18 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.tree-view .entry > .header,
|
||||
.tree-view .entry > .name {
|
||||
z-index: 1;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tree-view .selected > .highlight {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 24px;
|
||||
margin-top:-24px;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.tree-view .entry.file .name {
|
||||
|
||||
Reference in New Issue
Block a user