Skip to content

Commit 582bca9

Browse files
hebertialmeidaAdlai Holler
authored andcommitted
Fix failing batch fetch in some cases. (facebookarchive#3242)
* Fixed failed batch fetch caused by _deceleratingVelocity * Fixed indentation
1 parent b41816d commit 582bca9

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

Source/ASCollectionView.mm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ @interface ASCollectionView () <ASRangeControllerDataSource, ASRangeControllerDe
145145
unsigned int scrollViewWillBeginDragging:1;
146146
unsigned int scrollViewDidEndDragging:1;
147147
unsigned int scrollViewWillEndDragging:1;
148+
unsigned int scrollViewDidEndDecelerating:1;
148149
unsigned int collectionViewWillDisplayNodeForItem:1;
149150
unsigned int collectionViewWillDisplayNodeForItemDeprecated:1;
150151
unsigned int collectionViewDidEndDisplayingNodeForItem:1;
@@ -481,6 +482,7 @@ - (void)setAsyncDelegate:(id<ASCollectionDelegate>)asyncDelegate
481482

482483
_asyncDelegateFlags.scrollViewDidScroll = [_asyncDelegate respondsToSelector:@selector(scrollViewDidScroll:)];
483484
_asyncDelegateFlags.scrollViewWillEndDragging = [_asyncDelegate respondsToSelector:@selector(scrollViewWillEndDragging:withVelocity:targetContentOffset:)];
485+
_asyncDelegateFlags.scrollViewDidEndDecelerating = [_asyncDelegate respondsToSelector:@selector(scrollViewDidEndDecelerating:)];
484486
_asyncDelegateFlags.scrollViewWillBeginDragging = [_asyncDelegate respondsToSelector:@selector(scrollViewWillBeginDragging:)];
485487
_asyncDelegateFlags.scrollViewDidEndDragging = [_asyncDelegate respondsToSelector:@selector(scrollViewDidEndDragging:willDecelerate:)];
486488
_asyncDelegateFlags.collectionViewWillDisplayNodeForItem = [_asyncDelegate respondsToSelector:@selector(collectionView:willDisplayNode:forItemAtIndexPath:)];
@@ -1318,6 +1320,15 @@ - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoi
13181320
}
13191321
}
13201322

1323+
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
1324+
{
1325+
_deceleratingVelocity = CGPointZero;
1326+
1327+
if (_asyncDelegateFlags.scrollViewDidEndDecelerating) {
1328+
[_asyncDelegate scrollViewDidEndDecelerating:scrollView];
1329+
}
1330+
}
1331+
13211332
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
13221333
{
13231334
for (_ASCollectionViewCell *collectionCell in _cellsForVisibilityUpdates) {

Source/ASTableView.mm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ @interface ASTableView () <ASRangeControllerDataSource, ASRangeControllerDelegat
181181
unsigned int scrollViewWillBeginDragging:1;
182182
unsigned int scrollViewDidEndDragging:1;
183183
unsigned int scrollViewWillEndDragging:1;
184+
unsigned int scrollViewDidEndDecelerating:1;
184185
unsigned int tableNodeWillDisplayNodeForRow:1;
185186
unsigned int tableViewWillDisplayNodeForRow:1;
186187
unsigned int tableViewWillDisplayNodeForRowDeprecated:1;
@@ -431,6 +432,7 @@ - (void)setAsyncDelegate:(id<ASTableDelegate>)asyncDelegate
431432
_asyncDelegateFlags.tableViewDidEndDisplayingNodeForRow = [_asyncDelegate respondsToSelector:@selector(tableView:didEndDisplayingNode:forRowAtIndexPath:)];
432433
_asyncDelegateFlags.tableNodeDidEndDisplayingNodeForRow = [_asyncDelegate respondsToSelector:@selector(tableNode:didEndDisplayingRowWithNode:)];
433434
_asyncDelegateFlags.scrollViewWillEndDragging = [_asyncDelegate respondsToSelector:@selector(scrollViewWillEndDragging:withVelocity:targetContentOffset:)];
435+
_asyncDelegateFlags.scrollViewDidEndDecelerating = [_asyncDelegate respondsToSelector:@selector(scrollViewDidEndDecelerating:)];
434436
_asyncDelegateFlags.tableViewWillBeginBatchFetch = [_asyncDelegate respondsToSelector:@selector(tableView:willBeginBatchFetchWithContext:)];
435437
_asyncDelegateFlags.tableNodeWillBeginBatchFetch = [_asyncDelegate respondsToSelector:@selector(tableNode:willBeginBatchFetchWithContext:)];
436438
_asyncDelegateFlags.shouldBatchFetchForTableView = [_asyncDelegate respondsToSelector:@selector(shouldBatchFetchForTableView:)];
@@ -1199,6 +1201,15 @@ - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoi
11991201
}
12001202
}
12011203

1204+
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
1205+
{
1206+
_deceleratingVelocity = CGPointZero;
1207+
1208+
if (_asyncDelegateFlags.scrollViewDidEndDecelerating) {
1209+
[_asyncDelegate scrollViewDidEndDecelerating:scrollView];
1210+
}
1211+
}
1212+
12021213
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
12031214
{
12041215
for (_ASTableViewCell *tableViewCell in _cellsForVisibilityUpdates) {

Source/Details/ASDelegateProxy.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ - (BOOL)interceptsSelector:(SEL)selector
5454
selector == @selector(tableView:didEndDisplayingCell:forRowAtIndexPath:) ||
5555

5656
// used for batch fetching API
57-
selector == @selector(scrollViewWillEndDragging:withVelocity:targetContentOffset:)
57+
selector == @selector(scrollViewWillEndDragging:withVelocity:targetContentOffset:) ||
58+
selector == @selector(scrollViewDidEndDecelerating:)
5859
);
5960
}
6061

@@ -96,6 +97,7 @@ - (BOOL)interceptsSelector:(SEL)selector
9697

9798
// used for batch fetching API
9899
selector == @selector(scrollViewWillEndDragging:withVelocity:targetContentOffset:) ||
100+
selector == @selector(scrollViewDidEndDecelerating:) ||
99101

100102
// used for ASCellNode visibility
101103
selector == @selector(scrollViewDidScroll:) ||

0 commit comments

Comments
 (0)