Skip to content

Commit

Permalink
Add support for visible area scroll in minimap element update
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Dec 15, 2014
1 parent d2f59e3 commit f3b6856
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class MinimapElement extends HTMLElement
update: ->
@visibleArea.style.width = @clientWidth + 'px'
@visibleArea.style.height = @minimap.getTextEditorHeight() + 'px'
@visibleArea.style.top = (@minimap.getTextEditorScrollTop() - @minimap.getMinimapScrollTop()) + 'px'
@visibleArea.style.left = (@minimap.getTextEditorScrollLeft()) + 'px'

# ######## ## ######## ## ## ######## ## ## ########
# ## ## ## ### ### ## ### ## ##
Expand Down
20 changes: 18 additions & 2 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ describe 'MinimapElement', ->
[editor, minimap, largeSample, smallSample, jasmineContent, editorElement, minimapElement] = []

beforeEach ->
jasmineContent = document.body.querySelector('#jasmine-content')

atom.config.set 'minimap.charHeight', 4
atom.config.set 'minimap.charWidth', 2
atom.config.set 'minimap.interline', 1
Expand Down Expand Up @@ -48,6 +46,8 @@ describe 'MinimapElement', ->
[nextAnimationFrame, canvas, visibleArea] = []

beforeEach ->
jasmineContent = document.body.querySelector('#jasmine-content')

spyOn(window, "setInterval").andCallFake window.fakeSetInterval
spyOn(window, "clearInterval").andCallFake window.fakeClearInterval

Expand All @@ -63,6 +63,14 @@ describe 'MinimapElement', ->
styleNode = document.createElement('style')
styleNode.textContent = """
#{stylesheet}
atom-text-editor atom-text-editor-minimap, atom-text-editor::shadow atom-text-editor-minimap {
background: red;
}
atom-text-editor atom-text-editor-minimap::shadow .minimap-visible-area, atom-text-editor::shadow atom-text-editor-minimap::shadow .minimap-visible-area {
background: green;
}
"""

jasmineContent.appendChild(styleNode)
Expand All @@ -71,7 +79,10 @@ describe 'MinimapElement', ->
canvas = minimapElement.shadowRoot.querySelector('canvas')
editorElement.style.width = '200px'
editorElement.style.height = '50px'

jasmineContent.appendChild(editorElement)
editor.setScrollTop(1000)
editor.setScrollLeft(200)
minimapElement.attach()

it 'takes the height of the editor', ->
Expand All @@ -96,3 +107,8 @@ describe 'MinimapElement', ->
it 'sets the visible area width and height', ->
expect(visibleArea.offsetWidth).toEqual(minimapElement.clientWidth)
expect(visibleArea.offsetHeight).toBeCloseTo(minimap.getTextEditorHeight(), 0)

it 'sets the visible visible area offset', ->

expect(visibleArea.offsetTop).toBeCloseTo(minimap.getTextEditorScrollTop() - minimap.getMinimapScrollTop(), 0)
expect(visibleArea.offsetLeft).toBeCloseTo(minimap.getTextEditorScrollLeft(), 0)

0 comments on commit f3b6856

Please sign in to comment.