Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show gutter shadow on vertical scrolling #61

Merged
merged 4 commits into from
Jun 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/tool-bar-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ module.exports = class ToolBarView extends View
newElement = atom.views.getView newItem
nextElement = atom.views.getView nextItem
@.element.insertBefore newElement, nextElement
@drawGutter()
nextItem

removeItem: (item) ->
index = @items.indexOf item
@items.splice index, 1
element = atom.views.getView item
@.element.removeChild element
@drawGutter()

initialize: ->
@subscriptions = new CompositeDisposable
Expand Down Expand Up @@ -56,12 +58,16 @@ module.exports = class ToolBarView extends View
if atom.config.get 'tool-bar.visible'
@show()

@.element.addEventListener 'scroll', @drawGutter
window.addEventListener 'resize', @drawGutter

serialize: ->

destroy: ->
@subscriptions.dispose()
@detach() if @panel?
@panel.destroy() if @panel?
window.removeEventListener 'resize', @drawGutter

updateSize: (size) ->
@removeClass 'tool-bar-16px tool-bar-24px tool-bar-32px'
Expand All @@ -84,13 +90,26 @@ module.exports = class ToolBarView extends View

@updateMenu position

@drawGutter()

updateMenu: (position) ->
packagesMenu = _.find(atom.menu.template, ({label}) -> label is 'Packages' or label is '&Packages')
toolBarMenu = _.find(packagesMenu.submenu, ({label}) -> label is 'Tool Bar' or label is '&Tool Bar') if packagesMenu
positionsMenu = _.find(toolBarMenu.submenu, ({label}) -> label is 'Position' or label is '&Position') if toolBarMenu
positionMenu = _.find(positionsMenu.submenu, ({label}) -> label is position) if positionsMenu
positionMenu?.checked = true

drawGutter: =>
@removeClass 'gutter-top gutter-bottom'
visibleHeight = @height()
scrollHeight = @.element.scrollHeight
hiddenHeight = scrollHeight - visibleHeight
if visibleHeight < scrollHeight
if @scrollTop() > 0
@addClass 'gutter-top'
if @scrollTop() < hiddenHeight
@addClass 'gutter-bottom'

hide: ->
@detach() if @panel?
@panel.destroy() if @panel?
Expand Down
18 changes: 18 additions & 0 deletions styles/tool-bar.less
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@
&::-webkit-scrollbar {
display: none;
}

&.gutter-top::before,
&.gutter-bottom::after {
content: "";
height: 100%;
left: 0;
pointer-events: none;
position: absolute;
top: 0;
width: 100%;
z-index: 1;
}
&.gutter-top::before {
box-shadow: inset 0px 20px 25px -20px rgb(0, 0, 0);
}
&.gutter-bottom::after {
box-shadow: inset 0px -20px 25px -20px rgb(0, 0, 0);
}
}

.tool-bar-btn {
Expand Down