@@ -10,11 +10,23 @@ import {
1010 IGridDragStartEvent ,
1111 ILoopEvent ,
1212 isAnnotatedMouseEvent ,
13- isAnnotatedMouseEventOfType
13+ isAnnotatedMouseEventOfType ,
1414} from '../event-loop' ;
1515
16- const PROPS_TO_COPY_FROM_MOUSE_EVENTS : Array < keyof AnnotatedMouseEventUnion | 'layerX' | 'layerY' > =
17- [ 'clientX' , 'clientY' , 'gridX' , 'gridY' , 'layerX' , 'layerY' , 'row' , 'col' , 'realRow' , 'realCol' , 'virtualRow' , 'virtualCol' ] ;
16+ const PROPS_TO_COPY_FROM_MOUSE_EVENTS : Array < keyof AnnotatedMouseEventUnion | 'layerX' | 'layerY' > = [
17+ 'clientX' ,
18+ 'clientY' ,
19+ 'gridX' ,
20+ 'gridY' ,
21+ 'layerX' ,
22+ 'layerY' ,
23+ 'row' ,
24+ 'col' ,
25+ 'realRow' ,
26+ 'realCol' ,
27+ 'virtualRow' ,
28+ 'virtualCol' ,
29+ ] ;
1830
1931export interface IEventDimensionInfoGetter {
2032 view ( e : IAnnotatedEvent ) : number ;
@@ -52,7 +64,7 @@ export function create(grid: Grid) {
5264 } ,
5365 layerPx ( e : AnnotatedMouseEventUnion | IGridCustomMouseEvent ) {
5466 return ( e as any ) . layerY ;
55- }
67+ } ,
5668 } ,
5769 colInfo : {
5870 view ( e : IAnnotatedEvent ) {
@@ -69,7 +81,7 @@ export function create(grid: Grid) {
6981 } ,
7082 layerPx ( e : AnnotatedMouseEventUnion | IGridCustomMouseEvent ) {
7183 return ( e as any ) . layerX ;
72- }
84+ } ,
7385 } ,
7486 _annotateEvent ( e : EventUnion ) {
7587 if ( isAnnotatedMouseEvent ( e ) ) {
@@ -113,7 +125,7 @@ export function create(grid: Grid) {
113125
114126 function calculateColScrollDiff ( e : AnnotatedMouseEventUnion | IGridCustomMouseEvent ) {
115127 let colDiff = 0 ;
116- if ( e . clientX > ( grid . container && grid . container . getBoundingClientRect ( ) . right || window . innerWidth ) ) {
128+ if ( e . clientX > ( ( grid . container && grid . container . getBoundingClientRect ( ) . right ) || window . innerWidth ) ) {
117129 colDiff = 1 ;
118130 } else if ( grid . viewPort . toGridX ( e . clientX ) < grid . virtualPixelCellModel . fixedWidth ( ) ) {
119131 colDiff = - 1 ;
@@ -123,7 +135,7 @@ export function create(grid: Grid) {
123135
124136 function calculateRowScrollDiff ( e : AnnotatedMouseEventUnion | IGridCustomMouseEvent ) {
125137 let rowDiff = 0 ;
126- if ( e . clientY > ( grid . container && grid . container . getBoundingClientRect ( ) . bottom || window . innerHeight ) ) {
138+ if ( e . clientY > ( ( grid . container && grid . container . getBoundingClientRect ( ) . bottom ) || window . innerHeight ) ) {
127139 rowDiff = 1 ;
128140 } else if ( grid . viewPort . toGridY ( e . clientY ) < grid . virtualPixelCellModel . fixedHeight ( ) ) {
129141 rowDiff = - 1 ;
@@ -139,10 +151,8 @@ export function create(grid: Grid) {
139151 const lastX = downEvent . clientX ;
140152 const lastY = downEvent . clientY ;
141153 const unbindMove = grid . eventLoop . bind ( window , 'mousemove' , ( mousemoveEvent ) => {
142-
143154 if ( dragStarted && ! mousemoveEvent . which ) {
144155 // got a move event without mouse down which means we somehow missed the mouseup
145- console . log ( 'mousemove unbind, how on earth do these happen?' ) ;
146156 handleMouseUp ( mousemoveEvent ) ;
147157 return ;
148158 }
@@ -157,7 +167,7 @@ export function create(grid: Grid) {
157167 ' when the last position was ' ,
158168 lastX ,
159169 ',' ,
160- lastY
170+ lastY ,
161171 ) ;
162172 }
163173 createAndFireCustomMouseEvent ( 'grid-drag-start' , downEvent , ( dragStart : IGridDragStartEvent ) => {
@@ -185,7 +195,6 @@ export function create(grid: Grid) {
185195 grid . cellScrollModel . scrollTo ( grid . cellScrollModel . row + rowDiff , grid . cellScrollModel . col + colDiff ) ;
186196 } , 100 ) ;
187197 }
188-
189198 } ) ;
190199 } ;
191200 } ) ;
@@ -200,7 +209,6 @@ export function create(grid: Grid) {
200209 lastDragRow = mousemoveEvent . row ;
201210 lastDragCol = mousemoveEvent . col ;
202211 }
203-
204212 } ) ;
205213
206214 const unbindUp = grid . eventLoop . bind ( window , 'mouseup' , handleMouseUp ) ;
@@ -234,7 +242,7 @@ export function create(grid: Grid) {
234242 function createAndFireCustomMouseEvent (
235243 type : GridCustomMouseEventTypes ,
236244 e : AnnotatedMouseEventUnion ,
237- annotateEvent ?: ( e : ILoopEvent ) => any
245+ annotateEvent ?: ( e : ILoopEvent ) => any ,
238246 ) {
239247 let drag = createCustomEventFromMouseEvent ( type , e ) ;
240248 if ( annotateEvent ) {
@@ -251,4 +259,5 @@ export function create(grid: Grid) {
251259 return model ;
252260}
253261
254- export default create ;
262+ export default create ;
263+
0 commit comments