Skip to content

Commit

Permalink
Remove UICollectionViewLayoutAttributes cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
WenchaoD committed Apr 5, 2017
1 parent 3a3a328 commit e5355a2
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions Sources/FSPageViewLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FSPagerViewLayout: UICollectionViewLayout {
fileprivate var pagerView: FSPagerView? {
return self.collectionView?.superview?.superview as? FSPagerView
}
fileprivate var layoutAttributes: [IndexPath:FSPagerViewLayoutAttributes] = [:]
fileprivate var layoutAttributesQueue: [FSPagerViewLayoutAttributes] = []

fileprivate var isInfinite: Bool = true
fileprivate var collectionViewSize: CGSize = .zero
Expand Down Expand Up @@ -60,7 +60,6 @@ class FSPagerViewLayout: UICollectionViewLayout {
self.needsReprepare = false

self.collectionViewSize = collectionView.frame.size
self.layoutAttributes.removeAll()

// Calculate basic parameters/variables
self.numberOfSections = pagerView.numberOfSections(in: collectionView)
Expand Down Expand Up @@ -147,16 +146,11 @@ class FSPagerViewLayout: UICollectionViewLayout {
}

override open func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
var attributes = self.layoutAttributes[indexPath]
if attributes == nil {
attributes = FSPagerViewLayoutAttributes(forCellWith: indexPath)
self.layoutAttributes[indexPath] = attributes
}
let attributes = FSPagerViewLayoutAttributes(forCellWith: indexPath)
let frame = self.frame(for: indexPath)
let center = CGPoint(x: frame.midX, y: frame.midY)
attributes!.center = center
attributes!.size = self.actualItemSize
self.layoutAttributes[indexPath] = attributes
attributes.center = center
attributes.size = self.actualItemSize
return attributes
}

Expand Down

0 comments on commit e5355a2

Please sign in to comment.