Skip to content

Commit

Permalink
🐛 Fix minimap position relying upon node order
Browse files Browse the repository at this point in the history
Closes #358
  • Loading branch information
abe33 committed Jul 9, 2015
1 parent 494d83e commit 89c3b03
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
10 changes: 4 additions & 6 deletions lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ class MinimapElement extends HTMLElement
'minimap.displayMinimapOnLeft': (displayMinimapOnLeft) =>
swapPosition = @minimap? and displayMinimapOnLeft isnt @displayMinimapOnLeft
@displayMinimapOnLeft = displayMinimapOnLeft
@classList.toggle('left', displayMinimapOnLeft and @absoluteMode)

@swapMinimapPosition() if swapPosition
@swapMinimapPosition()

'minimap.minimapScrollIndicator': (@minimapScrollIndicator) =>
if @minimapScrollIndicator and not @scrollIndicator?
Expand Down Expand Up @@ -76,7 +75,6 @@ class MinimapElement extends HTMLElement

'minimap.absoluteMode': (@absoluteMode) =>
@classList.toggle('absolute', @absoluteMode)
@classList.toggle('left', @displayMinimapOnLeft and @absoluteMode)

# Internal: DOM callback invoked when a new {MinimapElement} is attached
# to the DOM.
Expand Down Expand Up @@ -118,18 +116,18 @@ class MinimapElement extends HTMLElement
# `displayMinimapOnLeft` setting.
attach: ->
return if @attached
@getTextEditorElementRoot().appendChild(this)
@swapMinimapPosition()
@attached = true

# Attaches the {MinimapElement} to the left of the target {TextEditorElement}.
attachToLeft: ->
root = @getTextEditorElementRoot()
root.insertBefore(this, root.children[0])
@classList.add('left')

# Attaches the {MinimapElement} to the right of the target
# {TextEditorElement}.
attachToRight: ->
@getTextEditorElementRoot().appendChild(this)
@classList.remove('left')

# Swaps the {MinimapElement} position based on the value of the
# `displayMinimapOnLeft` setting.
Expand Down
5 changes: 2 additions & 3 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ describe 'MinimapElement', ->
describe 'when minimap.displayMinimapOnLeft setting is true', ->
it 'moves the attached minimap to the left', ->
atom.config.set 'minimap.displayMinimapOnLeft', true
expect(Array::indexOf.call(editorElement.shadowRoot.children, minimapElement)).toEqual(0)
expect(minimapElement.classList.contains('left')).toBeTruthy()

describe 'when the minimap is not attached yet', ->
beforeEach ->
Expand All @@ -663,7 +663,7 @@ describe 'MinimapElement', ->
minimapElement.attach()

it 'moves the attached minimap to the left', ->
expect(Array::indexOf.call(editorElement.shadowRoot.children, minimapElement)).toEqual(0)
expect(minimapElement.classList.contains('left')).toBeTruthy()

describe 'when minimap.adjustMinimapWidthToSoftWrap is true', ->
[minimapWidth] = []
Expand Down Expand Up @@ -920,7 +920,6 @@ describe 'MinimapElement', ->
describe 'when the displayMinimapOnLeft setting is enabled', ->
beforeEach ->
atom.config.set('minimap.displayMinimapOnLeft', true)
nextAnimationFrame()

it 'adjusts the size of the control div to fit in the minimap', ->
expect(controls.clientWidth).toEqual(minimapElement.canvas.clientWidth / devicePixelRatio)
Expand Down
9 changes: 9 additions & 0 deletions styles/minimap.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@ atom-notifications:empty {
pointer-events: none
}

atom-text-editor::shadow .editor--private {
order: 2;
}

atom-text-editor::shadow, atom-text-editor {
atom-text-editor-minimap {
display: block;
width: 10%;
height: 100%;
overflow: hidden;
position: relative;
order: 2;

-webkit-user-select: none;

&.left {
order: 1;
}

&.absolute {
position: absolute;
right: 0;
Expand Down

0 comments on commit 89c3b03

Please sign in to comment.