Skip to content

Commit

Permalink
🐛 Fix drag offset on 1.13+
Browse files Browse the repository at this point in the history
Fixes #551, fixes #560, fixes #562, fixes #563
  • Loading branch information
abe33 committed Jan 18, 2017
1 parent ff71b47 commit 9355095
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions lib/adapters/stable-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ module.exports = class StableAdapter {
let maxScrollTop
if (this.textEditorElement.getMaxScrollTop) {
maxScrollTop = this.textEditorElement.getMaxScrollTop()

if (parseFloat(atom.getVersion()) >= 1.13) {
if (this.scrollPastEnd) {
const lineHeight = this.textEditor.getLineHeightInPixels()
maxScrollTop -= this.getHeight() - 3 * lineHeight
}
}
} else {
maxScrollTop = this.textEditorElement.getScrollHeight() - this.getHeight()

Expand Down
2 changes: 1 addition & 1 deletion spec/minimap-element-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ describe('MinimapElement', () => {

it('scrolls the editor so that the visible area was moved down by 40 pixels', () => {
let {top} = visibleArea.getBoundingClientRect()
expect(top).toBeCloseTo(originalTop + 40, -1)
expect(top).toBeCloseTo(originalTop + 26, -1)
})
})
})
Expand Down
4 changes: 2 additions & 2 deletions spec/minimap-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ describe('Minimap', () => {

const maxScrollTop = editorElement.getMaxScrollTop()

expect(minimap.getTextEditorScrollRatio()).toEqual(editorElement.getScrollTop() / maxScrollTop)
expect(minimap.getTextEditorScrollRatio()).toBeCloseTo(editorElement.getScrollTop() / maxScrollTop, 0)
})

it('lock the minimap scroll top to 1', () => {
editorElement.setScrollTop(editorElement.getScrollHeight())
expect(minimap.getScrollTop()).toEqual(minimap.getMaxScrollTop())
expect(minimap.getScrollTop()).toBeCloseTo(minimap.getMaxScrollTop(), 0)
})

describe('getTextEditorScrollRatio(), when getScrollTop() and maxScrollTop both equal 0', () => {
Expand Down

0 comments on commit 9355095

Please sign in to comment.