From 89c3b035419a119bd00cc5dcded2b2064589a377 Mon Sep 17 00:00:00 2001 From: abe33 Date: Fri, 10 Jul 2015 01:26:27 +0200 Subject: [PATCH] :bug: Fix minimap position relying upon node order Closes #358 --- lib/minimap-element.coffee | 10 ++++------ spec/minimap-element-spec.coffee | 5 ++--- styles/minimap.less | 9 +++++++++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/minimap-element.coffee b/lib/minimap-element.coffee index b17acb18..954a8d36 100644 --- a/lib/minimap-element.coffee +++ b/lib/minimap-element.coffee @@ -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? @@ -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. @@ -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. diff --git a/spec/minimap-element-spec.coffee b/spec/minimap-element-spec.coffee index b93465df..e37c75c8 100644 --- a/spec/minimap-element-spec.coffee +++ b/spec/minimap-element-spec.coffee @@ -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 -> @@ -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] = [] @@ -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) diff --git a/styles/minimap.less b/styles/minimap.less index 12a04100..782a5910 100644 --- a/styles/minimap.less +++ b/styles/minimap.less @@ -4,6 +4,10 @@ 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; @@ -11,9 +15,14 @@ atom-text-editor::shadow, atom-text-editorĀ { height: 100%; overflow: hidden; position: relative; + order: 2; -webkit-user-select: none; + &.left { + order: 1; + } + &.absolute { position: absolute; right: 0;