Skip to content

Commit 52ffe5c

Browse files
committed
fix: ios fix for cell update (disabling animations)
1 parent 1f2f2f1 commit 52ffe5c

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/collectionview.ios.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,12 @@ export class CollectionView extends CollectionViewBase {
190190
}
191191

192192
public onSourceCollectionChanged(event: ChangedData<any>) {
193-
if (!this.nativeViewProtected) {
193+
const view = this.nativeViewProtected;
194+
if (!view) {
194195
return;
195196
}
196197
if (Trace.isEnabled()) {
197-
CLog(CLogTypes.log, 'onItemsChanged', event.action, event.index, event.addedCount, event.removed && event.removed.length);
198+
CLog(CLogTypes.log, 'onItemsChanged',ChangeType.Update, event.action, event.index, event.addedCount, event.removed && event.removed.length);
198199
}
199200
// we need to clear stored cell sizes and it wont be correct anymore
200201
this.clearCellSize();
@@ -209,8 +210,8 @@ export class CollectionView extends CollectionViewBase {
209210
if (Trace.isEnabled()) {
210211
CLog(CLogTypes.info, 'deleteItemsAtIndexPaths', indexes.count);
211212
}
212-
this.nativeViewProtected.performBatchUpdatesCompletion(() => {
213-
this.nativeViewProtected.deleteItemsAtIndexPaths(indexes);
213+
view.performBatchUpdatesCompletion(() => {
214+
view.deleteItemsAtIndexPaths(indexes);
214215
}, null);
215216
return;
216217
}
@@ -220,9 +221,12 @@ export class CollectionView extends CollectionViewBase {
220221
if (Trace.isEnabled()) {
221222
CLog(CLogTypes.info, 'reloadItemsAtIndexPaths', indexes.count);
222223
}
223-
this.nativeViewProtected.performBatchUpdatesCompletion(() => {
224-
this.nativeViewProtected.reloadItemsAtIndexPaths(indexes);
225-
}, null);
224+
UIView.performWithoutAnimation(()=>{
225+
view.performBatchUpdatesCompletion(() => {
226+
view.reloadItemsAtIndexPaths(indexes);
227+
}, null);
228+
});
229+
226230
return;
227231
}
228232
case ChangeType.Add: {
@@ -233,20 +237,20 @@ export class CollectionView extends CollectionViewBase {
233237
if (Trace.isEnabled()) {
234238
CLog(CLogTypes.info, 'insertItemsAtIndexPaths', indexes.count);
235239
}
236-
this.nativeViewProtected.performBatchUpdatesCompletion(() => {
237-
this.nativeViewProtected.insertItemsAtIndexPaths(indexes);
240+
view.performBatchUpdatesCompletion(() => {
241+
view.insertItemsAtIndexPaths(indexes);
238242
}, null);
239243
// Reload the items to avoid duplicate Load on Demand indicators:
240244
return;
241245
}
242246
case ChangeType.Splice: {
243-
this.nativeViewProtected.performBatchUpdatesCompletion(() => {
247+
view.performBatchUpdatesCompletion(() => {
244248
if (event.addedCount > 0) {
245249
const indexes = NSMutableArray.alloc<NSIndexPath>().init();
246250
for (let index = 0; index < event.addedCount; index++) {
247251
indexes.addObject(NSIndexPath.indexPathForItemInSection(event.index + index, 0));
248252
}
249-
this.nativeViewProtected.insertItemsAtIndexPaths(indexes);
253+
view.insertItemsAtIndexPaths(indexes);
250254
}
251255
if (event.removed && event.removed.length > 0) {
252256
const indexes = NSMutableArray.new<NSIndexPath>();
@@ -257,15 +261,14 @@ export class CollectionView extends CollectionViewBase {
257261
if (Trace.isEnabled()) {
258262
CLog(CLogTypes.info, 'deleteItemsAtIndexPaths', indexes.count);
259263
}
260-
this.nativeViewProtected.performBatchUpdatesCompletion(() => {
261-
this.nativeViewProtected.deleteItemsAtIndexPaths(indexes);
264+
view.performBatchUpdatesCompletion(() => {
265+
view.deleteItemsAtIndexPaths(indexes);
262266
}, null);
263267
}
264268
}, null);
265269

266270
return;
267271
}
268-
// break;
269272
}
270273
this.refresh();
271274
}

0 commit comments

Comments
 (0)