From a77a94a981128a5a2f1335bc02729d510dfd8310 Mon Sep 17 00:00:00 2001 From: abe33 Date: Wed, 7 Jan 2015 20:24:48 +0100 Subject: [PATCH] :bug: Fix error raised when clicking on minimap Fixes #198 --- lib/minimap-view.coffee | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/minimap-view.coffee b/lib/minimap-view.coffee index 96a5c6de..471b1bb9 100644 --- a/lib/minimap-view.coffee +++ b/lib/minimap-view.coffee @@ -494,13 +494,15 @@ class MinimapView extends View e.preventDefault() e.stopPropagation() - y = e.pageY - @offsetTop - top = (y + @renderView.scrollTop()) / @scaleY + {pageY, target} = e + + y = pageY - target.getBoundingClientRect().top + row = Math.floor(y / @getLineHeight()) + @getFirstVisibleScreenRow() + + scrollTop = row * @getTextEditor().getLineHeightInPixels() - @getTextEditor().getHeight() / 2 - position = @editor.displayBuffer.screenPositionForPixelPosition({top, left: 0}) - @editor.scrollToScreenPosition(position, center: true) + @getTextEditor().setScrollTop(scrollTop) - # Fix trigger `mousewheel` event. setTimeout => @isClicked = false , 377