@@ -33,7 +33,6 @@ open class InfiniteCollectionView: UICollectionView {
3333 open weak var infiniteDataSource : InfiniteCollectionViewDataSource ?
3434 open weak var infiniteDelegate : InfiniteCollectionViewDelegate ?
3535 fileprivate var indexOffset : Int = 0
36- fileprivate var contentWidth : CGFloat = UIScreen . main. bounds. width
3736 fileprivate var pageIndex = 0
3837 @available ( * , deprecated, message: " It becomes unnecessary because it uses UICollectionViewFlowLayout. " )
3938 open var cellWidth : CGFloat ?
@@ -48,13 +47,8 @@ open class InfiniteCollectionView: UICollectionView {
4847 deinit {
4948 NotificationCenter . default. removeObserver ( self , name: . UIDeviceOrientationDidChange, object: nil )
5049 }
51- open override func reloadData( ) {
52- super. reloadData ( )
53- contentWidth = totalContentWidth
54- }
5550 open func rotate( _ notification: Notification ) {
56- contentWidth = totalContentWidth
57- contentOffset = CGPoint ( x: CGFloat ( pageIndex + indexOffset) * itemWidth, y: contentOffset. y)
51+ setContentOffset ( CGPoint ( x: CGFloat ( pageIndex + indexOffset) * itemWidth, y: contentOffset. y) , animated: false )
5852 }
5953}
6054
@@ -78,7 +72,7 @@ private extension InfiniteCollectionView {
7872 let currentOffset = contentOffset
7973 let centerX = ( scrollView. contentSize. width - bounds. width) / 2
8074 let distFromCenter = centerX - currentOffset. x
81- if fabs ( distFromCenter) > ( contentWidth / 4 ) {
75+ if fabs ( distFromCenter) > ( totalContentWidth / 4 ) {
8276 let cellcount = distFromCenter / itemWidth
8377 let shiftCells = Int ( ( cellcount > 0 ) ? floor ( cellcount) : ceil ( cellcount) )
8478 let offsetCorrection = ( abs ( cellcount) . truncatingRemainder ( dividingBy: 1 ) ) * itemWidth
0 commit comments