@@ -811,11 +811,18 @@ export class GridStack {
811
811
( ! forcePixel || ! this . opts . cellHeightUnit || this . opts . cellHeightUnit === 'px' ) ) {
812
812
return this . opts . cellHeight as number ;
813
813
}
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
+ }
814
821
// else get first cell height
815
822
let el = this . el . querySelector ( '.' + this . opts . itemClass ) as HTMLElement ;
816
823
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 ) ;
819
826
}
820
827
// else do entire grid and # of rows (but doesn't work if min-height is the actual constrain)
821
828
let rows = parseInt ( this . el . getAttribute ( 'gs-current-row' ) ) ;
@@ -1358,7 +1365,7 @@ export class GridStack {
1358
1365
if ( ! n ) return ;
1359
1366
const grid = n . grid ;
1360
1367
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 ) ;
1362
1369
if ( ! cell ) return ;
1363
1370
let height = n . h ? n . h * cell : el . clientHeight ; // getBoundingClientRect().height seem to flicker back and forth
1364
1371
let item : Element ;
@@ -1370,7 +1377,7 @@ export class GridStack {
1370
1377
let wantedH : number ;
1371
1378
if ( n . subGrid ) {
1372
1379
// 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 ) ;
1374
1381
} else {
1375
1382
// NOTE: clientHeight & getBoundingClientRect() is undefined for text and other leaf nodes. use <div> container!
1376
1383
const child = item . firstElementChild ;
0 commit comments