Skip to content

Commit 01e15fe

Browse files
committed
fix(ios): prevent performLayout to redraw items during refreshVisibleItems or refreh
1 parent 05a378e commit 01e15fe

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/collectionview/index.ios.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export class CollectionView extends CollectionViewBase {
8989
_dataSource: CollectionViewDataSource;
9090
_delegate: UICollectionViewDelegateImpl | UICollectionViewDelegateFixedSizeImpl;
9191
private _preparingCell: boolean = false;
92+
private _refreshingVisible: boolean = false;
9293
// private _sizes: number[][];
9394
private _map: Map<CollectionViewCell, ItemView>;
9495
_measureCellMap: Map<string, { cell: CollectionViewCell; view: View }>;
@@ -710,6 +711,7 @@ export class CollectionView extends CollectionViewBase {
710711
if (!view) {
711712
return;
712713
}
714+
this._refreshingVisible = true;
713715
const sizes: NSMutableArray<NSValue> = this._delegate instanceof UICollectionViewDelegateImpl ? this._delegate.cachedSizes : null;
714716

715717
const visibles = view.indexPathsForVisibleItems;
@@ -727,9 +729,14 @@ export class CollectionView extends CollectionViewBase {
727729
}
728730

729731
UIView.performWithoutAnimation(() => {
730-
view.performBatchUpdatesCompletion(() => {
731-
view.reloadItemsAtIndexPaths(visibles);
732-
}, null);
732+
view.performBatchUpdatesCompletion(
733+
() => {
734+
view.reloadItemsAtIndexPaths(visibles);
735+
},
736+
() => {
737+
this._refreshingVisible = false;
738+
}
739+
);
733740
});
734741
}
735742
public isItemAtIndexVisible(itemIndex: number): boolean {
@@ -921,7 +928,7 @@ export class CollectionView extends CollectionViewBase {
921928
// for a cell to update correctly on cell layout change we need
922929
// to do it ourself instead of "propagating it"
923930
view['performLayout'] = () => {
924-
if (!this._preparingCell && !view['inPerformLayout']) {
931+
if (!this._preparingCell && !this._refreshingVisible && !view['inPerformLayout']) {
925932
view['inPerformLayout'] = true;
926933
const index = cell.currentIndex;
927934
const nativeView = this.nativeViewProtected;

0 commit comments

Comments
 (0)