@@ -811,11 +811,18 @@ export class GridStack {
811811 ( ! forcePixel || ! this . opts . cellHeightUnit || this . opts . cellHeightUnit === 'px' ) ) {
812812 return this . opts . cellHeight as number ;
813813 }
814+ // do rem/em to px conversion
815+ if ( this . opts . cellHeightUnit === 'rem' ) {
816+ return ( this . opts . cellHeight as number ) * parseFloat ( getComputedStyle ( document . documentElement ) . fontSize ) ;
817+ }
818+ if ( this . opts . cellHeightUnit === 'em' ) {
819+ return ( this . opts . cellHeight as number ) * parseFloat ( getComputedStyle ( this . el ) . fontSize ) ;
820+ }
814821 // else get first cell height
815822 let el = this . el . querySelector ( '.' + this . opts . itemClass ) as HTMLElement ;
816823 if ( el ) {
817- let height = Utils . toNumber ( el . getAttribute ( 'gs-h' ) ) || 1 ; // since we don't write 1 anymore
818- return Math . round ( el . offsetHeight / height ) ;
824+ let h = Utils . toNumber ( el . getAttribute ( 'gs-h' ) ) || 1 ; // since we don't write 1 anymore
825+ return Math . round ( el . offsetHeight / h ) ;
819826 }
820827 // else do entire grid and # of rows (but doesn't work if min-height is the actual constrain)
821828 let rows = parseInt ( this . el . getAttribute ( 'gs-current-row' ) ) ;
@@ -1358,7 +1365,7 @@ export class GridStack {
13581365 if ( ! n ) return ;
13591366 const grid = n . grid ;
13601367 if ( ! grid || el . parentElement !== grid . el ) return ; // skip if we are not inside a grid
1361- const cell = grid . getCellHeight ( ) ;
1368+ const cell = grid . getCellHeight ( true ) ;
13621369 if ( ! cell ) return ;
13631370 let height = n . h ? n . h * cell : el . clientHeight ; // getBoundingClientRect().height seem to flicker back and forth
13641371 let item : Element ;
@@ -1370,7 +1377,7 @@ export class GridStack {
13701377 let wantedH : number ;
13711378 if ( n . subGrid ) {
13721379 // sub-grid - use their actual row count * their cell height
1373- wantedH = n . subGrid . getRow ( ) * n . subGrid . getCellHeight ( ) ;
1380+ wantedH = n . subGrid . getRow ( ) * n . subGrid . getCellHeight ( true ) ;
13741381 } else {
13751382 // NOTE: clientHeight & getBoundingClientRect() is undefined for text and other leaf nodes. use <div> container!
13761383 const child = item . firstElementChild ;
0 commit comments