From 93550956554dc42c547856556ce607ef64c97da8 Mon Sep 17 00:00:00 2001 From: abe33 Date: Wed, 18 Jan 2017 17:03:52 +0100 Subject: [PATCH] :bug: Fix drag offset on 1.13+ Fixes #551, fixes #560, fixes #562, fixes #563 --- lib/adapters/stable-adapter.js | 7 +++++++ spec/minimap-element-spec.js | 2 +- spec/minimap-spec.js | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/adapters/stable-adapter.js b/lib/adapters/stable-adapter.js index 057c1473..fcdc7e3c 100644 --- a/lib/adapters/stable-adapter.js +++ b/lib/adapters/stable-adapter.js @@ -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() diff --git a/spec/minimap-element-spec.js b/spec/minimap-element-spec.js index aa8ac47c..41843b50 100644 --- a/spec/minimap-element-spec.js +++ b/spec/minimap-element-spec.js @@ -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) }) }) }) diff --git a/spec/minimap-spec.js b/spec/minimap-spec.js index ff08e712..41c73c44 100644 --- a/spec/minimap-spec.js +++ b/spec/minimap-spec.js @@ -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', () => {