@@ -251,9 +251,10 @@ export class IgxColumnMovingDragDirective extends IgxDragDirective {
251
251
}
252
252
253
253
public onPointerDown ( event ) {
254
+ event . stopPropagation ( ) ;
254
255
255
- const resizeArea = document . elementFromPoint ( event . pageX , event . pageY ) ;
256
- if ( ! this . draggable || this . element . nativeElement . children [ 3 ] . isEqualNode ( resizeArea ) ) {
256
+ const el = document . elementFromPoint ( event . pageX , event . pageY ) ;
257
+ if ( ! this . draggable || el . getAttribute ( "id" ) === "resizeHandler" ) {
257
258
return ;
258
259
}
259
260
@@ -270,6 +271,7 @@ export class IgxColumnMovingDragDirective extends IgxDragDirective {
270
271
}
271
272
272
273
public onPointerMove ( event ) {
274
+ event . preventDefault ( ) ;
273
275
274
276
if ( ! this . draggable ) {
275
277
return ;
@@ -296,7 +298,9 @@ export class IgxColumnMovingDragDirective extends IgxDragDirective {
296
298
297
299
protected createDragGhost ( event ) {
298
300
super . createDragGhost ( event ) ;
299
- this . _dragGhost . removeChild ( this . _dragGhost . children [ 2 ] ) ;
301
+
302
+ this . _dragGhost . style . minWidth = null ;
303
+ this . _dragGhost . style . flexBasis = null ;
300
304
301
305
const icon = document . createElement ( 'i' ) ;
302
306
const text = document . createTextNode ( 'swap_horiz' ) ;
@@ -305,25 +309,23 @@ export class IgxColumnMovingDragDirective extends IgxDragDirective {
305
309
icon . classList . add ( 'material-icons' ) ;
306
310
this . renderer . addClass ( icon , this . _dragGhostImgIconClass ) ;
307
311
308
- this . _dragGhost . insertBefore ( icon , this . _dragGhost . children [ 1 ] ) ;
309
-
310
312
this . cms . icon = icon ;
311
313
312
- this . _dragGhost . style . minWidth = null ;
313
- this . _dragGhost . style . flexBasis = null ;
314
-
315
- const range = document . createRange ( ) ;
316
- range . selectNodeContents ( this . _dragGhost . children [ 2 ] ) ;
314
+ if ( ! this . column . columnGroup ) {
315
+ this . _dragGhost . removeChild ( this . _dragGhost . children [ 2 ] ) ;
316
+ this . _dragGhost . insertBefore ( icon , this . _dragGhost . children [ 1 ] ) ;
317
317
318
- const s = document . defaultView . getComputedStyle ( this . element . nativeElement ) ;
319
- this . _dragGhost . style . width = Math . ceil ( range . getBoundingClientRect ( ) . width +
320
- parseFloat ( s . borderRightWidth ) + parseFloat ( s . borderLeftWidth ) + parseFloat ( s . paddingLeft ) +
321
- parseFloat ( s . paddingRight ) + icon . getBoundingClientRect ( ) . width ) +
322
- parseFloat ( document . defaultView . getComputedStyle ( icon ) . marginRight ) + 'px' ;
318
+ this . left = this . _dragStartX = event . clientX - ( ( this . _dragGhost . getBoundingClientRect ( ) . width / 3 ) * 2 ) ;
319
+ this . top = this . _dragStartY = event . clientY - ( ( this . _dragGhost . getBoundingClientRect ( ) . height / 3 ) * 2 ) ;
320
+ } else {
321
+ this . _dragGhost . removeChild ( this . _dragGhost . children [ 2 ] ) ;
322
+ this . _dragGhost . removeChild ( this . _dragGhost . children [ 0 ] ) ;
323
+ this . _dragGhost . removeChild ( this . _dragGhost . children [ this . _dragGhost . children . length - 1 ] ) ;
324
+ this . renderer . addClass ( this . _dragGhost . children [ 0 ] , 'igx-grid__drag-ghost-group-image' ) ;
323
325
324
- this . left = this . _dragStartX = event . clientX -
325
- ( ( ( range . getBoundingClientRect ( ) . width + parseFloat ( s . paddingLeft ) + parseFloat ( s . paddingRight ) ) / 3 ) * 2 ) ;
326
- this . top = this . _dragStartY = event . clientY - ( ( parseFloat ( s . height ) / 3 ) * 2 ) ;
326
+ this . left = this . _dragStartX = event . clientX - ( ( this . _dragGhost . getBoundingClientRect ( ) . width / 3 ) * 2 ) ;
327
+ this . top = this . _dragStartY = event . clientY - ( ( this . _dragGhost . getBoundingClientRect ( ) . height / 3 ) * 2 ) ;
328
+ }
327
329
}
328
330
}
329
331
@@ -372,7 +374,10 @@ export class IgxColumnMovingDropDirective extends IgxDropDirective implements On
372
374
}
373
375
374
376
public onDragEnter ( event ) {
375
- if ( this . isDropTarget && this . cms . column !== this . column ) {
377
+ if ( this . isDropTarget &&
378
+ this . cms . column !== this . column &&
379
+ this . cms . column . level === this . column . level &&
380
+ this . cms . column . parent === this . column . parent ) {
376
381
const args = {
377
382
source : this . cms . column ,
378
383
target : this . column ,
@@ -386,8 +391,8 @@ export class IgxColumnMovingDropDirective extends IgxDropDirective implements On
386
391
}
387
392
388
393
if ( ! this . column . pinned || ( this . column . pinned && this . cms . column . pinned ) ) {
389
- this . _dropIndicator = this . cms . column . index < this . column . index ? this . elementRef . nativeElement . children [ 4 ] :
390
- this . elementRef . nativeElement . children [ 0 ] ;
394
+ this . _dropIndicator = this . cms . column . index < this . column . index ? this . elementRef . nativeElement . lastElementChild :
395
+ this . elementRef . nativeElement . firstElementChild ;
391
396
392
397
this . renderer . addClass ( this . _dropIndicator , this . _dropIndicatorClass ) ;
393
398
@@ -398,16 +403,16 @@ export class IgxColumnMovingDropDirective extends IgxDropDirective implements On
398
403
const nextPinnedWidth = this . column . grid . getPinnedWidth ( ) + parseFloat ( this . cms . column . width ) ;
399
404
400
405
if ( nextPinnedWidth <= this . column . grid . calcPinnedContainerMaxWidth ) {
401
- this . _dropIndicator = this . elementRef . nativeElement . children [ 0 ] ;
402
- this . renderer . addClass ( this . _dropIndicator , this . _dropIndicatorClass ) ;
403
-
404
406
this . cms . icon . innerText = 'lock' ;
407
+
408
+ this . _dropIndicator = this . elementRef . nativeElement . firstElementChild ;
409
+ this . renderer . addClass ( this . _dropIndicator , this . _dropIndicatorClass ) ;
405
410
} else {
406
411
this . cms . icon . innerText = 'block' ;
407
412
}
408
413
}
409
414
} else {
410
- this . cms . icon . innerText = 'swap_horiz ' ;
415
+ this . cms . icon . innerText = 'block ' ;
411
416
}
412
417
413
418
if ( this . horizontalScroll ) {
@@ -462,8 +467,10 @@ export class IgxColumnMovingDropDirective extends IgxDropDirective implements On
462
467
nextPinnedWidth = this . column . grid . getPinnedWidth ( ) + parseFloat ( this . cms . column . width ) ;
463
468
}
464
469
465
- if ( args . cancel || ( nextPinnedWidth && nextPinnedWidth > this . column . grid . calcPinnedContainerMaxWidth ) ) {
466
- return ;
470
+ if ( args . cancel || ( nextPinnedWidth && nextPinnedWidth > this . column . grid . calcPinnedContainerMaxWidth ) ||
471
+ this . column . level !== this . cms . column . level ||
472
+ this . column . parent !== this . cms . column . parent ) {
473
+ return ;
467
474
}
468
475
469
476
this . column . grid . moveColumn ( this . cms . column , this . column ) ;
0 commit comments