MaherKSantina / MSPeekCollectionViewDelegateImplementation

A custom paging behavior that peeks the previous and next items in a collection view
https://medium.com/@maher.santina90/how-to-create-cells-that-peek-on-the-sides-like-ios-11-app-store-ef4bb54c0c7d
MIT License
356 stars 32 forks source link

`targetContentOffset` bugfix #33

Closed om-ha closed 5 years ago

om-ha commented 5 years ago

This fixes targetContentOffset bug in scrollViewWillEndDragging where the offset is a multiplier of the UICollectionView bounds' width if UICollectionView paging is enabled.

om-ha commented 5 years ago

All items (except first and last one) had incorrect offset when scrolling because isPagingEnabled was set to true from Interface Builder or previously when setting up the collection view (which other developers might miss). This is making the UICollectionView instance not honor targetContentOffset in scrollViewWillEndDragging but rather use a multiplier of UICollectionView instance bounds width.

MaherKSantina commented 5 years ago

Ohh man I'm really sorry you wasted your time trying to figure this out. I added the step to disable paging in the Medium article but haven't added it to the configuration function 😢 Thank you so much for the contribution. I'll merge this PR and create a new release

om-ha commented 5 years ago

No problem, in a way it was beneficial trying to pin this one that I understood how your implementation works, and gained more insight about UICollectionView's inner-workings. Many thanks for the great library!

MaherKSantina commented 5 years ago

Much appreciated mate! I'm glad it was of good help for you 👍