File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -144,6 +144,8 @@ import UIKit
144144 internal var cachedAttributes = [ CollectionViewSlantedLayoutAttributes] ( )
145145 /// :nodoc:
146146 internal var cachedContentSize : CGFloat = 0
147+ /// :nodoc:
148+ internal var currentSize : CGSize = CGSize . zero
147149
148150 /// :nodoc:
149151 fileprivate func itemSize( forItemAt indexPath: IndexPath ) -> ( value: CGFloat , isDynamic: Bool ) {
@@ -215,6 +217,7 @@ import UIKit
215217 cachedAttributes = [ CollectionViewSlantedLayoutAttributes] ( )
216218 cachedContentSize = 0
217219 }
220+
218221}
219222
220223// MARK: CollectionViewLayout methods overriding
@@ -231,6 +234,9 @@ extension CollectionViewSlantedLayout {
231234
232235 /// :nodoc:
233236 override open func shouldInvalidateLayout( forBoundsChange newBounds: CGRect ) -> Bool {
237+ guard newBounds. size != currentSize else {
238+ return false
239+ }
234240 invalidateCache ( )
235241 return true
236242 }
@@ -241,8 +247,8 @@ extension CollectionViewSlantedLayout {
241247 return
242248 }
243249
250+ currentSize = collectionView? . bounds. size ?? CGSize . zero
244251 let staticMasks = calculatedMasks ( itemSize: max ( itemSize, 0 ) )
245-
246252 var position : CGFloat = 0
247253
248254 for item in 0 ..< numberOfItems {
You can’t perform that action at this time.
0 commit comments