1- {View } = require ' atom'
1+ {$ , View } = require ' atom'
22
33MinimapEditorView = require ' ./minimap-editor-view'
44
55CONFIGS = require ' ./config'
66
7+ require ' ./resizeend.js'
8+
79minTop = 0
810maxTop = 0
911
@@ -25,11 +27,12 @@ class MinimapView extends View
2527 initialize : ->
2628 @ attach ()
2729
28- @ on ' mousewheel' , @mouseWheel . bind ( this )
29- @ on ' mousedown' , @mouseDown . bind ( this )
30+ @ on ' mousewheel' , @mouseWheel
31+ @ on ' mousedown' , @mouseDown
3032
3133 @ subscribe @paneView .model .$activeItem , @onActiveItemChanged
3234 @ subscribe @paneView .model , ' destroy' , => @ destroy ()
35+ @ subscribe $ (window ), ' resize:end' , @resizeend
3336
3437 # @subscribe atom.workspaceView, 'cursor:moved', =>
3538 # @update()
@@ -64,6 +67,12 @@ class MinimapView extends View
6467 @scrollView = @editorView .find (' .scroll-view' )
6568 @scrollViewLines = @scrollView .find (' .lines' )
6669
70+ # current editor bind scrollTop event
71+ @editor .off ' scroll-top-changed.editor'
72+ @editor .on ' scroll-top-changed.editor' , @scrollTop
73+ @editor .off ' scroll-left-changed.editor'
74+ @editor .on ' scroll-left-changed.editor' , @scrollLeft
75+
6776
6877 # wtf? Long long function!
6978 updateMinimapView : ->
@@ -91,12 +100,6 @@ class MinimapView extends View
91100 # offset minimap
92101 @ offset ({ ' top' : @editorView .offset ().top })
93102
94- # current editor bind scrollTop event
95- @editor .off (' scroll-top-changed.editor' )
96- @editor .on (' scroll-top-changed.editor' , @scrollTop .bind (this ))
97- @editor .off (' scroll-left-changed.editor' )
98- @editor .on (' scroll-left-changed.editor' , @scrollLeft .bind (this ))
99-
100103 # reset minimap layer size
101104 @ reset ()
102105
@@ -135,18 +138,18 @@ class MinimapView extends View
135138 getScrollViewClientRect : ->
136139 @scrollViewLines [0 ].getBoundingClientRect ()
137140
138- mouseWheel : (e ) - >
141+ mouseWheel : (e ) = >
139142 return if @isClicked
140143 {wheelDeltaX , wheelDeltaY } = e .originalEvent
141144 if wheelDeltaX
142145 @editorView .scrollLeft (@editorView .scrollLeft () - wheelDeltaX)
143146 if wheelDeltaY
144147 @editorView .scrollTop (@editorView .scrollTop () - wheelDeltaY)
145148
146- scrollLeft : (left ) - >
149+ scrollLeft : (left ) = >
147150 @miniScrollView .scrollLeft (left * scaleX)
148151
149- scrollTop : (top ) - >
152+ scrollTop : (top ) = >
150153 h = @miniEditorView .height () * scaleY
151154 miniOverLayerHeight = @miniOverlayer .height ()
152155 n = top / (@scrollViewLines .outerHeight () - miniOverLayerHeight)
@@ -164,7 +167,7 @@ class MinimapView extends View
164167 @miniOverlayer [0 ].style .transform = ' translate3d(0, ' + (n * (@miniEditorView .height () - miniOverLayerHeight)) + ' px, 0)'
165168
166169 isClicked : false
167- mouseDown : (e ) - >
170+ mouseDown : (e ) = >
168171 @isClicked = true
169172 e .preventDefault ()
170173 e .stopPropagation
@@ -190,3 +193,6 @@ class MinimapView extends View
190193 @ [0 ].style .width = width + ' px'
191194 @ [0 ].style .webkitTransform =
192195 @ [0 ].style .transform = scaleStr + ' ' + translateStr
196+
197+ resizeend : (status ) =>
198+ @ updateMinimapView ()
0 commit comments