pronebird / UIScrollView-InfiniteScroll

UIScrollView ∞ scroll category
MIT License
1.06k stars 148 forks source link

infiniteScrollTriggerOffset not working with collectionview #51

Closed sagariosdev closed 7 years ago

sagariosdev commented 7 years ago

CustomInfiniteIndicator *indicator = [[CustomInfiniteIndicator alloc] initWithFrame:indicatorRect];

self.collectionView.infiniteScrollIndicatorView = indicator;

// Add infinite scroll handler
[self.collectionView addInfiniteScrollWithHandler:^(UICollectionView *collectionView) {
self.pageNumber = self.pageNumber + 1 ;
   [weakSelf fetchData:^{
        // Finish infinite scroll animations
        [collectionView finishInfiniteScroll];
    }];
}];

[self.collectionView beginInfiniteScroll:YES];

self.collectionView.infiniteScrollTriggerOffset = 400;

In my project collectionview scroll direction vertical is set. at a time I'm loading 48 cells and each row contains 3 cell so 16 rows filled with it also cell width height is SCREEN_WIDTH/3 ARE return

So if I running with device 5s then it must be triggered when scroll and reaching row 5 but it should not triggered until end of collection view scroll.

sagariosdev commented 7 years ago

Okey so, I'm closing this issue right now. I understand and fixed it. simply increase infiniteScrollTriggerOffset value high to trigger event early.

pronebird commented 7 years ago

Hey,

The formula is:

when = (contentSize - triggerOffset)

You would have to adjust the value per device. You can use screen bounds to calculate desired trigger offset.

sagariosdev commented 7 years ago

Yeah, I had calculated triggered offset. Thanks. @pronebird