Skip to content

Commit

Permalink
🐛 Fix position of the quick settings view when minimap is on left
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Feb 11, 2015
1 parent 6434c34 commit 0d45445
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,13 @@ class MinimapElement extends HTMLElement
@quickSettingsElement = null

@quickSettingsElement.attach()
{top, left} = @getBoundingClientRect()
{top, left, right} = @getBoundingClientRect()
@quickSettingsElement.style.top = top + 'px'
@quickSettingsElement.style.left = (left - @quickSettingsElement.clientWidth) + 'px'

if @displayMinimapOnLeft
@quickSettingsElement.style.left = (right) + 'px'
else
@quickSettingsElement.style.left = (left - @quickSettingsElement.clientWidth) + 'px'

disposeOpenQuickSettings: ->
return unless @openQuickSettings?
Expand Down
23 changes: 23 additions & 0 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,29 @@ describe 'MinimapElement', ->
expect(realOffsetTop(quickSettingsElement)).toBeCloseTo(minimapBounds.top, 0)
expect(realOffsetLeft(quickSettingsElement)).toBeCloseTo(minimapBounds.left - settingsBounds.width, 0)

describe 'when the displayMinimapOnLeft setting is enabled', ->
describe 'clicking on the div', ->
beforeEach ->
atom.config.set('minimap.displayMinimapOnLeft', true)

workspaceElement = atom.views.getView(atom.workspace)
jasmineContent.appendChild(workspaceElement)

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

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

afterEach ->
minimapElement.quickSettingsElement.destroy()

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

expect(realOffsetTop(quickSettingsElement)).toBeCloseTo(minimapBounds.top, 0)
expect(realOffsetLeft(quickSettingsElement)).toBeCloseTo(minimapBounds.right, 0)

describe 'when the quick settings view is open', ->
beforeEach ->
workspaceElement = atom.views.getView(atom.workspace)
Expand Down

0 comments on commit 0d45445

Please sign in to comment.