From e9c501c908b160cc4a86df9eebe911866fae6c0a Mon Sep 17 00:00:00 2001 From: abe33 Date: Wed, 10 Dec 2014 12:52:21 +0100 Subject: [PATCH] :bug: Fix broken scroll when clicking the minimap Fixes #171 --- lib/minimap-view.coffee | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/minimap-view.coffee b/lib/minimap-view.coffee index c6e471bb..8bdfb466 100644 --- a/lib/minimap-view.coffee +++ b/lib/minimap-view.coffee @@ -493,11 +493,13 @@ class MinimapView extends View @isClicked = true e.preventDefault() e.stopPropagation() - # VisibleArea's center-y + y = e.pageY - @offsetTop - top = @indicator.computeFromCenterY(y) / @scaleY - # @note: currently, no animation. - @editor.scrollToScreenPosition({top, left: 0}) + top = (y + @renderView.scrollTop()) / @scaleY + + position = @editor.displayBuffer.screenPositionForPixelPosition({top, left: 0}) + @editor.scrollToScreenPosition(position, center: true) + # Fix trigger `mousewheel` event. setTimeout => @isClicked = false