Skip to content

Commit

Permalink
Implement canvas offset to allow smooth scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Dec 15, 2014
1 parent 6555bfe commit 57accd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/minimap-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class MinimapElement extends HTMLElement
@visibleArea.style.top = (@minimap.getTextEditorScrollTop() - @minimap.getMinimapScrollTop()) + 'px'
@visibleArea.style.left = (@minimap.getTextEditorScrollLeft()) + 'px'

@canvas.style.top = (@minimap.getFirstVisibleScreenRow() * @minimap.getLineHeight() - @minimap.getMinimapScrollTop()) + 'px'

@updateCanvas()

# ######## ## ######## ## ## ######## ## ## ########
Expand Down
6 changes: 6 additions & 0 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ describe 'MinimapElement', ->
expect(visibleArea.offsetTop).toBeCloseTo(minimap.getTextEditorScrollTop() - minimap.getMinimapScrollTop(), 0)
expect(visibleArea.offsetLeft).toBeCloseTo(minimap.getTextEditorScrollLeft(), 0)

it 'offsets the canvas when the scroll does not match line height', ->
editor.setScrollTop(1004)
nextAnimationFrame()

expect(canvas.offsetTop).toEqual(-2)

describe 'when the editor is scrolled', ->
beforeEach ->
editor.setScrollTop(2000)
Expand Down

0 comments on commit 57accd3

Please sign in to comment.