Skip to content

Commit

Permalink
Position the quick settings view relatively to the minimap
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Dec 17, 2014
1 parent 2533ae2 commit f28f41d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ class MinimapElement extends HTMLElement

@quickSettingsView = new MinimapQuickSettingsView(this)
@quickSettingsView.attach()
{top, left} = @getBoundingClientRect()
@quickSettingsView.css({
top: top + 'px'
left: (left - @quickSettingsView.width()) + 'px'
})

disposeOpenQuickSettings: ->
@shadowRoot.removeChild(@openQuickSettings)
Expand Down
14 changes: 12 additions & 2 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ describe 'MinimapElement', ->
# ###### ######## ## ## #### ## ## ###### ######

describe 'when minimap.displayPluginsControls setting is true', ->
[openQuickSettings, workspaceElement] = []
[openQuickSettings, quickSettingsView, workspaceElement] = []
beforeEach ->
atom.config.set 'minimap.displayPluginsControls', true

Expand All @@ -439,15 +439,25 @@ describe 'MinimapElement', ->
describe 'clicking on the div', ->
beforeEach ->
workspaceElement = atom.views.getView(atom.workspace)
jasmineContent.appendChild(workspaceElement)

openQuickSettings = minimapElement.shadowRoot.querySelector('.open-minimap-quick-settings')
click(openQuickSettings)

quickSettingsView = workspaceElement.querySelector('.minimap-quick-settings')

afterEach ->
minimapElement.quickSettingsView.destroy()

it 'opens the quick settings view', ->
expect(workspaceElement.querySelector('.minimap-quick-settings')).toExist()
expect(quickSettingsView).toExist()

it 'position the quick settings view next to the minimap', ->
minimapBounds = minimapElement.getBoundingClientRect()
settingsBounds = quickSettingsView.getBoundingClientRect()

expect(realOffsetTop(quickSettingsView)).toBeCloseTo(minimapBounds.top, 0)
expect(realOffsetLeft(quickSettingsView)).toBeCloseTo(minimapBounds.left - settingsBounds.width, 0)

describe 'then disabling it', ->
beforeEach ->
Expand Down

0 comments on commit f28f41d

Please sign in to comment.