@@ -68,6 +68,15 @@ export default class IgcTileComponent extends EventEmitterMixin<
6868 private _disableDrag = false ;
6969 private _fullscreen = false ;
7070 private _maximized = false ;
71+ private _initialPointerX : number | null = null ;
72+ private _initialPointerY : number | null = null ;
73+ private _cachedStyles : {
74+ ghostBackground ?: string ;
75+ ghostBorder ?: string ;
76+ ghostBorderRadius ?: string ;
77+ ghostMinWidth ?: string ;
78+ ghostMinHeight ?: string ;
79+ } = { } ;
7180 private _context = new ContextProvider ( this , {
7281 context : tileContext ,
7382 initialValue : this ,
@@ -333,9 +342,43 @@ export default class IgcTileComponent extends EventEmitterMixin<
333342 this . _isDragging = false ;
334343 }
335344
336- private _handleResize ( _ : CustomEvent < ResizeCallbackParams > ) {
345+ private cacheStyles ( ) {
346+ const computedStyle = window . getComputedStyle ( this ) ;
347+
348+ this . _cachedStyles = {
349+ ghostBackground : computedStyle . getPropertyValue (
350+ '--placeholder-background'
351+ ) ,
352+ ghostBorder : computedStyle . getPropertyValue ( '--ghost-border' ) ,
353+ ghostBorderRadius : computedStyle . getPropertyValue ( '--border-radius' ) ,
354+ ghostMinWidth : computedStyle . getPropertyValue ( '--ig-min-col-width' ) ,
355+ ghostMinHeight : computedStyle . getPropertyValue ( '--ig-min-row-height' ) ,
356+ } ;
357+ }
358+
359+ private _handleResizeStart ( event : CustomEvent < ResizeCallbackParams > ) {
360+ const ghostElement = event . detail . state . ghost ;
361+ this . _initialPointerX = event . detail . event . clientX ;
362+ this . _initialPointerY = event . detail . event . clientY ;
363+
364+ if ( ghostElement ) {
365+ ghostElement . style . minWidth = this . _cachedStyles . ghostMinWidth ! ;
366+ ghostElement . style . minHeight = this . _cachedStyles . ghostMinHeight ! ;
367+ }
368+ }
369+
370+ private _handleResize ( event : CustomEvent < ResizeCallbackParams > ) {
337371 this . _isResizing = true ;
338- // console.log(event.detail.state);
372+
373+ const ghostElement = event . detail . state . current ;
374+
375+ if ( ghostElement ) {
376+ const deltaX = event . detail . event . clientX - this . _initialPointerX ! ;
377+ const deltaY = event . detail . event . clientY - this . _initialPointerY ! ;
378+
379+ ghostElement . width = event . detail . state . initial . width + deltaX ;
380+ ghostElement . height = event . detail . state . initial . height + deltaY ;
381+ }
339382 }
340383
341384 private _handleResizeEnd ( event : CustomEvent < ResizeCallbackParams > ) {
@@ -360,43 +403,26 @@ export default class IgcTileComponent extends EventEmitterMixin<
360403 } ) ;
361404
362405 this . _isResizing = false ;
406+ this . _initialPointerX = null ;
407+ this . _initialPointerY = null ;
408+ this . _cachedStyles = { } ;
363409 }
364410
365411 // REVIEW
366412 protected ghostFactory = ( ) => {
367- const ghostBackground = window
368- . getComputedStyle ( this )
369- . getPropertyValue ( '--placeholder-background' ) ;
370-
371- const ghostBorder = window
372- . getComputedStyle ( this )
373- . getPropertyValue ( '--ghost-border' ) ;
374-
375- const ghostBorderRadius = window
376- . getComputedStyle ( this )
377- . getPropertyValue ( '--border-radius' ) ;
378-
379- const ghostMinWidth = window
380- . getComputedStyle ( this )
381- . getPropertyValue ( '--ig-min-col-width' ) ;
382-
383- const ghostMinHeight = window
384- . getComputedStyle ( this )
385- . getPropertyValue ( '--ig-min-row-height' ) ;
413+ this . cacheStyles ( ) ;
386414
387415 const ghost = document . createElement ( 'div' ) ;
388416 Object . assign ( ghost . style , {
389417 position : 'absolute' ,
390418 top : 0 ,
391419 left : 0 ,
392420 zIndex : 1000 ,
393- background : ghostBackground ,
394- border : `1px solid ${ ghostBorder } ` ,
395- borderRadius : ghostBorderRadius ,
421+ background : this . _cachedStyles . ghostBackground ,
422+ border : `1px solid ${ this . _cachedStyles . ghostBorder } ` ,
423+ borderRadius : this . _cachedStyles . ghostBorderRadius ,
396424 width : '100%' ,
397425 height : '100%' ,
398- minWidth : ghostMinWidth ,
399- minHeight : ghostMinHeight ,
400426 gridRow : '' ,
401427 gridColumn : '' ,
402428 } ) ;
@@ -444,6 +470,7 @@ export default class IgcTileComponent extends EventEmitterMixin<
444470 part ="resize "
445471 .ghostFactory =${ this . ghostFactory }
446472 mode ="deferred"
473+ @igcResizeStart=${ this . _handleResizeStart }
447474 @igcResize=${ this . _handleResize }
448475 @igcResizeEnd=${ this . _handleResizeEnd }
449476 >
0 commit comments