@@ -41,8 +41,13 @@ export class IgxColumnResizerDirective implements OnInit, OnDestroy {
4141 @Output ( ) public resize = new Subject < any > ( ) ;
4242
4343 private _left : number ;
44+ private _ratio : number = 1 ;
4445 private _destroy = new Subject < boolean > ( ) ;
4546
47+ public get ratio ( ) : number {
48+ return this . _ratio ;
49+ }
50+
4651 constructor (
4752 public element : ElementRef < HTMLElement > ,
4853 @Inject ( DOCUMENT ) public document ,
@@ -56,7 +61,7 @@ export class IgxColumnResizerDirective implements OnInit, OnDestroy {
5661 . pipe (
5762 takeUntil ( this . _destroy ) ,
5863 takeUntil < MouseEvent > ( this . resizeEnd ) ,
59- map ( ( event ) => event . clientX - offset ) ,
64+ map ( ( event ) => ( event . clientX - offset ) / ( this . _ratio ) ) ,
6065 ) )
6166 )
6267 . subscribe ( ( pos ) => {
@@ -113,8 +118,12 @@ export class IgxColumnResizerDirective implements OnInit, OnDestroy {
113118 public onMousedown ( event : MouseEvent ) {
114119 event . preventDefault ( ) ;
115120 const parent = this . element . nativeElement . parentElement . parentElement ;
116-
117- this . left = this . _left = event . clientX - parent . getBoundingClientRect ( ) . left ;
121+ const parentRectWidth = parent . getBoundingClientRect ( ) . width ;
122+ const parentComputedWidth = parseFloat ( window . getComputedStyle ( parent ) . width ) ;
123+ if ( parentRectWidth && parentComputedWidth && parentRectWidth / parentComputedWidth !== 1 ) {
124+ this . _ratio = parentRectWidth / parentComputedWidth ;
125+ }
126+ this . left = this . _left = ( event . clientX - parent . getBoundingClientRect ( ) . left ) / ( this . _ratio ) ;
118127 this . top = ( event . target as HTMLElement ) . getBoundingClientRect ( ) . top - parent . getBoundingClientRect ( ) . top ;
119128
120129 this . resizeStart . next ( event ) ;
0 commit comments