Skip to content

Commit 863f97c

Browse files
committed
splite updateScrollX and updateScrollY
1 parent ba280a0 commit 863f97c

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

lib/minimap-indicator.coffee

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,34 @@ class Indicator extends Rectangle
6464
@minBoundaryY = 0
6565
@maxBoundaryY = @maxPosY
6666

67-
updateRatio: ->
67+
setX: (@x) ->
68+
@updateRatioX()
69+
@updateScrollerPositionX()
70+
71+
setY: (@y) ->
72+
@updateRatioY()
73+
@updateScrollerPositionY()
74+
75+
updateRatioX: ->
6876
@ratioX = @x / @maxPosX if @maxPosX isnt 0
77+
78+
updateRatioY: ->
6979
@ratioY = @y / @maxPosY if @maxPosY isnt 0
7080

71-
updateScrollerPosition: ->
81+
updateRatio: ->
82+
@updateRatioX()
83+
@updateRatioY()
84+
85+
updateScrollerPositionX: ->
7286
@scroller.x = - @ratioX * @scroller.maxScrollX
87+
88+
updateScrollerPositionY: ->
7389
@scroller.y = - @ratioY * @scroller.maxScrollY
7490

91+
updateScrollerPosition: ->
92+
@updateScrollerPositionX()
93+
@updateScrollerPositionY()
94+
7595
updatePosition: ->
7696
x = Math.round @ratioX * @scroller.maxScrollX
7797
y = Math.round @ratioY * @scroller.maxScrollY

lib/minimap-view.coffee

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class MinimapView extends View
3434
@transform @miniWrapper[0], @minimapScale
3535
# dragging's status
3636
@isPressed = false
37+
@offsetLeft = 0
3738
@offsetTop = 0
3839
@indicator = new MinimapIndicator()
3940

@@ -96,8 +97,9 @@ class MinimapView extends View
9697

9798
subscribeToEditor: ->
9899
@subscribe @editor, 'screen-lines-changed.minimap', @updateMinimapEditorView
99-
@subscribe @editor, 'scroll-top-changed.minimap', @updateScroll
100-
#@subscribe @editor, 'scroll-left-changed.minimap', @updateScroll
100+
@subscribe @editor, 'scroll-top-changed.minimap', @updateScrollY
101+
# Hacked scroll-left
102+
@subscribe @scrollView, 'scroll.minimap', @updateScrollX
101103

102104
# See /Applications/Atom.app/Contents/Resources/app/src/pane-view.js#349
103105
# pane-view's private api
@@ -160,7 +162,7 @@ class MinimapView extends View
160162

161163
setImmediate => @updateScroll()
162164

163-
updateScroll: (top) =>
165+
updateScrollY: (top) =>
164166
# Need scroll-top value when in find pane or on Vim mode(`gg`, `shift+g`).
165167
# Or we can find a better solution.
166168
if top?
@@ -170,10 +172,18 @@ class MinimapView extends View
170172
overlayerOffset = @scrollView.find('.overlayer').offset().top
171173
overlayY = -overlayerOffset + scrollViewOffset
172174

173-
@indicator.y = overlayY
174-
@indicator.updateRatio()
175-
@indicator.updateScrollerPosition()
175+
@indicator.setY(overlayY)
176+
@updatePositions()
176177

178+
updateScrollX: =>
179+
@indicator.setX(@scrollView[0].scrollLeft)
180+
@updatePositions()
181+
182+
updateScroll: =>
183+
@updateScrollX()
184+
@updateScrollY()
185+
186+
updatePositions: ->
177187
@transform @miniVisibleArea[0], @translate(@indicator.x, @indicator.y)
178188
@transform @miniWrapper[0], @minimapScale + @translate(@indicator.scroller.x, @indicator.scroller.y)
179189

0 commit comments

Comments
 (0)