@@ -63,6 +63,7 @@ export class CollectionView extends CollectionViewBase {
6363 private _sizes : number [ ] [ ] ;
6464 private _map : Map < CollectionViewCell , ItemView > ;
6565 _measureCellMap : Map < string , { cell : CollectionViewCell ; view : View } > ;
66+ _lastLayoutKey : string ;
6667
6768 nativeViewProtected : UICollectionView ;
6869
@@ -194,7 +195,6 @@ export class CollectionView extends CollectionViewBase {
194195 callback ( view ) ;
195196 } ) ;
196197 }
197-
198198 public onLayout ( left : number , top : number , right : number , bottom : number ) {
199199 super . onLayout ( left , top , right , bottom ) ;
200200
@@ -215,13 +215,12 @@ export class CollectionView extends CollectionViewBase {
215215
216216 layoutView . invalidateLayout ( ) ;
217217
218- // this._map.forEach((cellView, cell) => {
219- // if (Trace.isEnabled()) {
220- // CLog(CLogTypes.log, 'onLayout', 'cell', cellView._listViewItemIndex);
221- // }
222- // this.layoutCell(cellView._listViewItemIndex, cell, cellView);
223- // });
224- this . refresh ( ) ;
218+ // there is no need to call refresh if it was triggered before with same size.
219+ // this refresh is just to handle size change
220+ const layoutKey = this . _innerWidth + '_' + this . _innerHeight ;
221+ if ( this . _lastLayoutKey !== layoutKey ) {
222+ this . refresh ( ) ;
223+ }
225224 }
226225
227226 public isHorizontal ( ) {
@@ -347,6 +346,7 @@ export class CollectionView extends CollectionViewBase {
347346 return ;
348347 }
349348 this . _isDataDirty = false ;
349+ this . _lastLayoutKey = this . _innerWidth + '_' + this . _innerHeight ;
350350 if ( Trace . isEnabled ( ) ) {
351351 CLog ( CLogTypes . info , 'refresh' ) ;
352352 }
0 commit comments