@@ -266,7 +266,8 @@ export class DashboardPage implements OnInit {
266266 }
267267 this . gridsterOptions . fixedRowHeight = cellSize ;
268268 }
269- this . gridsterOptions . api ?. optionsChanged ( ) ;
269+ this . sortPanelsForMobile ( ) ;
270+ this . gridsterOptions . api ?. optionsChanged ( ) ;
270271 }
271272
272273 public async loadDashboard ( ) {
@@ -283,6 +284,7 @@ export class DashboardPage implements OnInit {
283284 this . globalFilter ?. initOrderDependentFilters ( dashboard . config . orderDependentFilters || [ ] ) ; // Filtros dependientes
284285 this . globalFilter ?. initGlobalFilters ( dashboard . config . filters || [ ] ) ; // Filtres del dashboard
285286 this . initPanels ( dashboard ) ;
287+ this . sortPanelsForMobile ( ) ;
286288 this . styles = dashboard . config . styles || this . stylesProviderService . generateDefaultStyles ( ) ;
287289 this . getUrlParams ( ) ;
288290 this . globalFilter . findGlobalFilterByUrlParams ( this . queryParams ) ;
@@ -497,7 +499,8 @@ export class DashboardPage implements OnInit {
497499 }
498500
499501 let valor = this . getBottomMostItem ( ) ;
500- this . height = valor !== undefined ? ( valor . y + valor . rows + 4 ) * 50 : 750 ;
502+ const rowHeight = this . gridsterOptions . fixedRowHeight || 150 ;
503+ this . height = valor !== undefined ? ( valor . y + valor . rows + 4 ) * rowHeight + 150 : 750 ;
501504 this . cdr . detectChanges ( ) ;
502505 this . stylesProviderService . loadedPanels -- ;
503506 }
@@ -1242,10 +1245,16 @@ public startCountdown(seconds: number) {
12421245 // Función que cambia el valor de la altura del gridster cada vez que hay un cambio en el elemento
12431246 onItemChange ( item : GridsterItem ) : void {
12441247 if ( this . panels ) {
1245- let valor = this . getBottomMostItem ( ) ;
1246- this . height = ( ( valor . y + valor . rows + 4 ) * 50 ) ;
1247- this . cdr . detectChanges ( ) ;
1248- }
1248+ const rowHeight = this . gridsterOptions . fixedRowHeight || 150 ;
1249+ const isMobile = window . innerWidth < ( this . gridsterOptions . mobileBreakpoint || 640 ) ;
1250+ if ( isMobile ) {
1251+ this . updateMobileHeight ( ) ;
1252+ } else {
1253+ let valor = this . getBottomMostItem ( ) ;
1254+ this . height = ( ( valor . y + valor . rows + 4 ) * rowHeight ) + 250 ;
1255+ this . cdr . detectChanges ( ) ;
1256+ }
1257+ }
12491258 }
12501259
12511260
@@ -1305,4 +1314,28 @@ public startCountdown(seconds: number) {
13051314 }
13061315 return tableMatch && columnMatch && labelMatch ;
13071316 }
1317+
1318+ // Funciones auxiliares para mobile
1319+ private updateMobileHeight ( ) : void {
1320+ const interval = setInterval ( ( ) => {
1321+ if ( this . stylesProviderService . loadedPanels <= 0 ) {
1322+ clearInterval ( interval ) ;
1323+ const gridsterEl = document . querySelector ( 'gridster' ) as HTMLElement ;
1324+ if ( gridsterEl ) {
1325+ this . height = gridsterEl . offsetHeight + 50 ;
1326+ this . cdr . detectChanges ( ) ;
1327+ }
1328+ }
1329+ } , 100 ) ;
1330+ setTimeout ( ( ) => clearInterval ( interval ) , 15000 ) ;
1331+ }
1332+
1333+ private sortPanelsForMobile ( ) : void {
1334+ if ( ! this . panels ?. length ) return ;
1335+ const isMobile = window . innerWidth < ( this . gridsterOptions . mobileBreakpoint || 640 ) ;
1336+ if ( isMobile ) {
1337+ this . panels . sort ( ( a , b ) => Math . floor ( a . y / 10 ) - Math . floor ( b . y / 10 ) || Math . floor ( a . x / 10 ) - Math . floor ( b . x / 10 ) ) ;
1338+ this . updateMobileHeight ( ) ;
1339+ }
1340+ }
13081341}
0 commit comments