Skip to content

Commit

Permalink
Add an absolute mode setting allowing the text editor content to flow…
Browse files Browse the repository at this point in the history
… below the minimap

Closes #337
  • Loading branch information
abe33 committed Jun 5, 2015
1 parent 247a9f6 commit 2fa132f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Below is the list of available plugins so far:
* `Scroll Animation`: Enable animations when scrolling the editor by clicking on the Minimap.
* `Scroll Animation Duration`: Duration of the scroll animation when clicking on the Minimap.
* `Use Hardware Acceleration`: If checked the Minimap scroll is done using a `translate3d` transform, otherwise the `translate` transform is used. (default=true)
* `Absolute Mode`: When enabled the minimap uses an absolute positioning, letting the editor's content flow below the minimap.
Note that this setting will do nothing if `Display Minimap On Left` is also enabled.

For instance the following result is obtained by setting a `Char Height` of `1px`:

Expand Down
4 changes: 4 additions & 0 deletions lib/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class Main
createPluginInDevMode:
type: 'boolean'
default: false
absoluteMode:
type: 'boolean'
default: false
description: 'When enabled the text editor content will be able to flow below the minimap.'

# Internal: The activation state of the minimap package.
active: false
Expand Down
5 changes: 5 additions & 0 deletions lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class MinimapElement extends HTMLElement
'minimap.displayMinimapOnLeft': (displayMinimapOnLeft) =>
swapPosition = @minimap? and displayMinimapOnLeft isnt @displayMinimapOnLeft
@displayMinimapOnLeft = displayMinimapOnLeft
@classList.toggle('left', displayMinimapOnLeft and @absoluteMode)

@swapMinimapPosition() if swapPosition

Expand Down Expand Up @@ -73,6 +74,10 @@ class MinimapElement extends HTMLElement
'minimap.useHardwareAcceleration': (@useHardwareAcceleration) =>
@requestUpdate() if @attached

'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.
attachedCallback: ->
Expand Down
14 changes: 14 additions & 0 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,20 @@ describe 'MinimapElement', ->
it 'attaches the scroll indicator', ->
expect(minimapElement.shadowRoot.querySelector('.minimap-scroll-indicator')).toExist()

describe 'when minimap.absoluteMode setting is true', ->
beforeEach ->
atom.config.set('minimap.absoluteMode', true)

it 'adds a absolute class to the minimap element', ->
expect(minimapElement.classList.contains('absolute')).toBeTruthy()

describe 'when minimap.displayMinimapOnLeft setting is true', ->
it 'also adds a left class to the minmap element', ->
atom.config.set('minimap.displayMinimapOnLeft', true)
expect(minimapElement.classList.contains('absolute')).toBeTruthy()
expect(minimapElement.classList.contains('left')).toBeTruthy()


# ####### ## ## #### ###### ## ##
# ## ## ## ## ## ## ## ## ##
# ## ## ## ## ## ## ## ##
Expand Down
12 changes: 12 additions & 0 deletions styles/minimap.less
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ atom-text-editor::shadow, atom-text-editor {

-webkit-user-select: none;

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

// absolute mode do nothing when the minimap is on the left, because
// it would conflict with the editor's gutter
&.left {
position: relative;
right: initial;
}
}

&::shadow {
canvas {
position: absolute;
Expand Down

0 comments on commit 2fa132f

Please sign in to comment.