@@ -52,7 +52,6 @@ export const createResizer = (
5252 const mountedIndexes = new WeakMap < Element , number > ( ) ;
5353
5454 const resizeObserver = createResizeObserver ( ( entries ) => {
55- const resizes : ItemResize [ ] = [ ] ;
5655 for ( const { target, contentRect } of entries ) {
5756 // Skip zero-sized rects that may be observed under `display: none` style
5857 if ( ! ( target as HTMLElement ) . offsetParent ) continue ;
@@ -62,14 +61,10 @@ export const createResizer = (
6261 } else {
6362 const index = mountedIndexes . get ( target ) ;
6463 if ( index != NULL ) {
65- resizes . push ( [ index , contentRect [ sizeKey ] ] ) ;
64+ store . $update ( ACTION_ITEM_RESIZE , [ index , contentRect [ sizeKey ] ] ) ;
6665 }
6766 }
6867 }
69-
70- if ( resizes . length ) {
71- store . $update ( ACTION_ITEM_RESIZE , resizes ) ;
72- }
7368 } ) ;
7469
7570 return {
@@ -106,20 +101,15 @@ export const createWindowResizer = (
106101 const mountedIndexes = new WeakMap < Element , number > ( ) ;
107102
108103 const resizeObserver = createResizeObserver ( ( entries ) => {
109- const resizes : ItemResize [ ] = [ ] ;
110104 for ( const { target, contentRect } of entries ) {
111105 // Skip zero-sized rects that may be observed under `display: none` style
112106 if ( ! ( target as HTMLElement ) . offsetParent ) continue ;
113107
114108 const index = mountedIndexes . get ( target ) ;
115109 if ( index != NULL ) {
116- resizes . push ( [ index , contentRect [ sizeKey ] ] ) ;
110+ store . $update ( ACTION_ITEM_RESIZE , [ index , contentRect [ sizeKey ] ] ) ;
117111 }
118112 }
119-
120- if ( resizes . length ) {
121- store . $update ( ACTION_ITEM_RESIZE , resizes ) ;
122- }
123113 } ) ;
124114
125115 let cleanupOnWindowResize : ( ( ) => void ) | undefined ;
@@ -221,7 +211,6 @@ export const createGridResizer = (
221211 }
222212
223213 if ( resizedRows . size ) {
224- const heightResizes : ItemResize [ ] = [ ] ;
225214 resizedRows . forEach ( ( rowIndex ) => {
226215 let maxHeight = 0 ;
227216 maybeCachedColIndexes . forEach ( ( colIndex ) => {
@@ -231,13 +220,11 @@ export const createGridResizer = (
231220 }
232221 } ) ;
233222 if ( maxHeight ) {
234- heightResizes . push ( [ rowIndex , maxHeight ] ) ;
223+ vStore . $update ( ACTION_ITEM_RESIZE , [ rowIndex , maxHeight ] ) ;
235224 }
236225 } ) ;
237- vStore . $update ( ACTION_ITEM_RESIZE , heightResizes ) ;
238226 }
239227 if ( resizedCols . size ) {
240- const widthResizes : ItemResize [ ] = [ ] ;
241228 resizedCols . forEach ( ( colIndex ) => {
242229 let maxWidth = 0 ;
243230 maybeCachedRowIndexes . forEach ( ( rowIndex ) => {
@@ -247,10 +234,9 @@ export const createGridResizer = (
247234 }
248235 } ) ;
249236 if ( maxWidth ) {
250- widthResizes . push ( [ colIndex , maxWidth ] ) ;
237+ hStore . $update ( ACTION_ITEM_RESIZE , [ colIndex , maxWidth ] ) ;
251238 }
252239 } ) ;
253- hStore . $update ( ACTION_ITEM_RESIZE , widthResizes ) ;
254240 }
255241 } ) ;
256242
@@ -269,20 +255,20 @@ export const createGridResizer = (
269255 } ;
270256 } ,
271257 $resizeCols ( cols : ItemResize [ ] ) {
272- for ( const [ c ] of cols ) {
258+ for ( const col of cols ) {
273259 for ( let r = 0 ; r < vStore . $getItemsLength ( ) ; r ++ ) {
274- sizeCache . delete ( getKey ( r , c ) ) ;
260+ sizeCache . delete ( getKey ( r , col [ 0 ] ) ) ;
275261 }
262+ hStore . $update ( ACTION_ITEM_RESIZE , col ) ;
276263 }
277- hStore . $update ( ACTION_ITEM_RESIZE , cols ) ;
278264 } ,
279265 $resizeRows ( rows : ItemResize [ ] ) {
280- for ( const [ r ] of rows ) {
266+ for ( const row of rows ) {
281267 for ( let c = 0 ; c < hStore . $getItemsLength ( ) ; c ++ ) {
282- sizeCache . delete ( getKey ( r , c ) ) ;
268+ sizeCache . delete ( getKey ( row [ 0 ] , c ) ) ;
283269 }
270+ vStore . $update ( ACTION_ITEM_RESIZE , row ) ;
284271 }
285- vStore . $update ( ACTION_ITEM_RESIZE , rows ) ;
286272 } ,
287273 $dispose : resizeObserver . _dispose ,
288274 } ;
0 commit comments