@@ -1183,28 +1183,29 @@ class MinimapElement {
11831183 offsetTop : this . getBoundingClientRect ( ) . top
11841184 }
11851185
1186+ // TODO can we avoid adding and removing the listeners every time?
1187+
11861188 const mousemoveHandler = ( e ) => this . drag ( extractMouseEventData ( e ) , initial )
1187- const mouseupHandler = ( e ) => this . endDrag ( )
1189+ const dragendHandler = ( ) => this . endDrag ( )
11881190
11891191 const touchmoveHandler = ( e ) => this . drag ( extractTouchEventData ( e ) , initial )
1190- const touchendHandler = ( e ) => this . endDrag ( )
11911192
11921193 document . body . addEventListener ( 'mousemove' , mousemoveHandler , { passive : true } )
1193- document . body . addEventListener ( 'mouseup' , mouseupHandler , { passive : true } )
1194- document . body . addEventListener ( 'mouseleave' , mouseupHandler , { passive : true } )
1194+ document . body . addEventListener ( 'mouseup' , dragendHandler , { passive : true } )
1195+ document . body . addEventListener ( 'mouseleave' , dragendHandler , { passive : true } )
11951196
11961197 document . body . addEventListener ( 'touchmove' , touchmoveHandler , { passive : true } )
1197- document . body . addEventListener ( 'touchend' , touchendHandler , { passive : true } )
1198- document . body . addEventListener ( 'touchcancel' , touchendHandler , { passive : true } )
1198+ document . body . addEventListener ( 'touchend' , dragendHandler , { passive : true } )
1199+ document . body . addEventListener ( 'touchcancel' , dragendHandler , { passive : true } )
11991200
12001201 this . dragSubscription = new Disposable ( function ( ) {
12011202 document . body . removeEventListener ( 'mousemove' , mousemoveHandler )
1202- document . body . removeEventListener ( 'mouseup' , mouseupHandler )
1203- document . body . removeEventListener ( 'mouseleave' , mouseupHandler )
1203+ document . body . removeEventListener ( 'mouseup' , dragendHandler )
1204+ document . body . removeEventListener ( 'mouseleave' , dragendHandler )
12041205
12051206 document . body . removeEventListener ( 'touchmove' , touchmoveHandler )
1206- document . body . removeEventListener ( 'touchend' , touchendHandler )
1207- document . body . removeEventListener ( 'touchcancel' , touchendHandler )
1207+ document . body . removeEventListener ( 'touchend' , dragendHandler )
1208+ document . body . removeEventListener ( 'touchcancel' , dragendHandler )
12081209 } )
12091210 }
12101211
0 commit comments