@@ -10,6 +10,15 @@ import * as header from './header/_export.mjs';
1010 * @extends Neo.container.Base
1111 */
1212class GridContainer extends BaseContainer {
13+ /**
14+ * @member {Object} delayable
15+ * @protected
16+ * @static
17+ */
18+ static delayable = {
19+ onResize : { type : 'buffer' , timer : 300 }
20+ }
21+
1322 static config = {
1423 /**
1524 * @member {String} className='Neo.grid.Container'
@@ -170,6 +179,7 @@ class GridContainer extends BaseContainer {
170179 me . createColumns ( me . columns ) ;
171180
172181 me . addDomListeners ( {
182+ resize : me . onResize ,
173183 scroll : me . onScroll ,
174184 scope : me
175185 } )
@@ -228,14 +238,22 @@ class GridContainer extends BaseContainer {
228238 afterSetMounted ( value , oldValue ) {
229239 super . afterSetMounted ( value , oldValue ) ;
230240
231- let me = this ;
241+ let me = this ,
242+ { ResizeObserver} = Neo . main . addon ,
243+ resizeParams = { id : me . id , windowId : me . windowId } ;
232244
233- value && me . getDomRect ( [ me . id , me . headerToolbarId ] ) . then ( ( [ containerRect , headerRect ] ) => {
234- me . view . set ( {
235- availableHeight : containerRect . height - headerRect . height ,
236- containerWidth : containerRect . width
245+ if ( value ) {
246+ ResizeObserver . register ( resizeParams ) ;
247+
248+ me . getDomRect ( [ me . id , me . headerToolbarId ] ) . then ( ( [ containerRect , headerRect ] ) => {
249+ me . view . set ( {
250+ availableHeight : containerRect . height - headerRect . height ,
251+ containerWidth : containerRect . width
252+ } )
237253 } )
238- } )
254+ } else if ( ! value && oldValue ) { // unmount
255+ ResizeObserver . unregister ( resizeParams )
256+ }
239257 }
240258
241259 /**
@@ -454,6 +472,20 @@ class GridContainer extends BaseContainer {
454472 me . view . createViewData ( )
455473 }
456474
475+ /**
476+ * @param args
477+ */
478+ destroy ( ...args ) {
479+ let me = this ;
480+
481+ me . mounted && Neo . main . addon . ResizeObserver . unregister ( {
482+ id : me . id ,
483+ windowId : me . windowId
484+ } ) ;
485+
486+ super . destroy ( ...args )
487+ }
488+
457489 /**
458490 * @override
459491 * @returns {* }
@@ -492,6 +524,13 @@ class GridContainer extends BaseContainer {
492524 this . selectionModel ?. register ( this )
493525 }
494526
527+ /**
528+ * @param {Object } data
529+ */
530+ onResize ( data ) {
531+ console . log ( 'onResize' , data )
532+ }
533+
495534 /**
496535 * @param {Object } data
497536 */
0 commit comments