Skip to content

Commit

Permalink
Add a with-minimal attribute on text editors
Browse files Browse the repository at this point in the history
Gives a way to hide the scrollbar only when a minimap is present, as
requested in #479
  • Loading branch information
abe33 committed May 20, 2016
1 parent bddefaf commit d76d410
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/minimap-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ export default class MinimapElement {
* @access private
*/
detachedCallback () {
this.getTextEditorElement().removeAttribute('with-minimap')
this.attached = false
}

Expand Down Expand Up @@ -369,6 +370,10 @@ export default class MinimapElement {
attach (parent) {
if (this.attached) { return }
(parent || this.getTextEditorElementRoot()).appendChild(this)

if (!parent) {
this.getTextEditorElement().setAttribute('with-minimap', '')
}
}

/**
Expand Down
12 changes: 12 additions & 0 deletions spec/minimap-element-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ describe('MinimapElement', () => {
window.requestAnimationFrame = requestAnimationFrameSafe
})

it('adds a with-minimap attribute on the text editor element', () => {
expect(editorElement.hasAttribute('with-minimap')).toBeTruthy()
})

it('takes the height of the editor', () => {
expect(minimapElement.offsetHeight).toEqual(editorElement.clientHeight)

Expand All @@ -144,6 +148,14 @@ describe('MinimapElement', () => {
expect(minimapElement.frameRequested).toBeTruthy()
})

describe('when detached', () => {
it('removes the attribute from the editor', () => {
minimapElement.detach()

expect(editorElement.hasAttribute('with-minimap')).toBeFalsy()
})
})

// ###### ###### ######
// ## ## ## ## ## ##
// ## ## ##
Expand Down

0 comments on commit d76d410

Please sign in to comment.