Hello!
First of all wanted to thank you for such an amazing library! :)
I am trying to implement infinitely scrolling collection view with timer, so that it periodically slides to next indexPath.
Currently what I am doing is, I have function that looks like this, and I just call it every like 5 seconds.
func scrollToNextPage() {
guard let currentPage = collectionView.centeredIndexPath?.row else { return }
collectionView.scrollToItem(at: IndexPath(item: currentPage + 1, section: 0), at: .centeredHorizontally, animated: true)
But after some time, it throws an error:
'NSInvalidArgumentException', reason: 'attempt to scroll to invalid index path: <NSIndexPath: 0x282bb0980> {length = 2, path = 0 - 162}'
I have also trying to doing like this instead:
collectionView.scrollToItem(at: collectionView.indexPath(from: IndexPath(item: currentPage + 1, section: 0)), at: .centeredHorizontally, animated: true)
But the problem with this one is that when it gets to the last (supposedly last in the raw data source) item, when it scrolls to the first one it does it with animation of scrolling all the items back to the first one, but desired behavior is that it scrolls from the last item to the first with like "swiping right" animation, just ordinary scrolling to next item.
BR