Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Closed
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
14 changes: 13 additions & 1 deletion lib/tab-bar-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class TabBarView extends HTMLElement
'tabs:split-left': => @splitTab('splitLeft')
'tabs:split-right': => @splitTab('splitRight')

@addEventListener "mouseenter", @onMouseEnter
@addEventListener "mouseleave", @onMouseLeave
@addEventListener "dragstart", @onDragStart
@addEventListener "dragend", @onDragEnd
@addEventListener "dragleave", @onDragLeave
Expand Down Expand Up @@ -163,7 +165,7 @@ class TabBarView extends HTMLElement
@closeTab(tab)
pathsToOpen = [atom.project.getPaths(), itemURI].reduce ((a, b) -> a.concat(b)), []
atom.open({pathsToOpen: pathsToOpen, newWindow: true, devMode: atom.devMode, safeMode: atom.safeMode})

splitTab: (fn) ->
if item = @querySelector('.right-clicked')?.item
if copiedItem = @copyItem(item)
Expand Down Expand Up @@ -459,4 +461,14 @@ class TabBarView extends HTMLElement
else
closest(target, '.tab-bar')

onMouseEnter: ->
for tab in @getTabs()
{width} = tab.getBoundingClientRect()
tab.style.maxWidth = width.toFixed(2) + 'px'
return

onMouseLeave: ->
tab.style.maxWidth = '' for tab in @getTabs()
return

module.exports = document.registerElement("atom-tabs", prototype: TabBarView.prototype, extends: "ul")
22 changes: 22 additions & 0 deletions spec/tabs-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,28 @@ describe "TabBarView", ->
afterEach ->
deserializerDisposable.dispose()

describe "when the mouse is moved over the tab bar", ->
it "fixes the width on every tab", ->
jasmine.attachToDOM(tabBar)

event = triggerMouseEvent('mouseenter', tabBar)

initialWidth1 = tabBar.tabAtIndex(0).getBoundingClientRect().width.toFixed(2)
initialWidth2 = tabBar.tabAtIndex(2).getBoundingClientRect().width.toFixed(2)

expect(tabBar.tabAtIndex(0).style.maxWidth).toBe initialWidth1 + 'px'
expect(tabBar.tabAtIndex(2).style.maxWidth).toBe initialWidth2 + 'px'

describe "when the mouse is moved away from the tab bar", ->
it "resets the width on every tab", ->
jasmine.attachToDOM(tabBar)

event = triggerMouseEvent('mouseenter', tabBar)
event = triggerMouseEvent('mouseleave', tabBar)

expect(tabBar.tabAtIndex(0).style.maxWidth).toBe ''
expect(tabBar.tabAtIndex(1).style.maxWidth).toBe ''

describe ".initialize(pane)", ->
it "creates a tab for each item on the tab bar's parent pane", ->
expect(pane.getItems().length).toBe 3
Expand Down
1 change: 1 addition & 0 deletions styles/tabs.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-webkit-flex: 1;
max-width: 175px;
min-width: 40px;
transition: max-width .25s ease-in;

@simurai simurai Jun 10, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too critical, but how about ease-in-out? Then it doesn't stop too abruptly.


&.active {
-webkit-flex: 2;
Expand Down