From 25968533bd98cefe1eabfba4e21aa567152bc574 Mon Sep 17 00:00:00 2001 From: Toby Brennan <contact@apptekstudios.com> Date: Sun, 5 Jul 2020 00:03:36 +1000 Subject: [PATCH] Minor code change --- .../Implementation/ASCollectionView.swift | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Sources/ASCollectionView/Implementation/ASCollectionView.swift b/Sources/ASCollectionView/Implementation/ASCollectionView.swift index b3355d8..743b225 100644 --- a/Sources/ASCollectionView/Implementation/ASCollectionView.swift +++ b/Sources/ASCollectionView/Implementation/ASCollectionView.swift @@ -836,14 +836,17 @@ public struct ASCollectionView<SectionID: Hashable>: UIViewControllerRepresentab var lastContentSize: CGSize = .zero func didUpdateContentSize(_ size: CGSize) { - guard let cv = collectionViewController?.collectionView, cv.contentSize != lastContentSize, cv.contentSize.width != 0, cv.contentSize.height != 0 else { return } - let firstSize = lastContentSize == .zero - lastContentSize = cv.contentSize - parent.contentSizeTracker?.contentSize = size - - DispatchQueue.main.async { - self.parent.invalidateParentCellLayout?(!firstSize) - } + guard let cv = collectionViewController?.collectionView, cv.contentSize.width != .zero, cv.contentSize.height != .zero else { return } + + if cv.contentSize != lastContentSize { + let firstSize = lastContentSize == .zero + lastContentSize = cv.contentSize + parent.contentSizeTracker?.contentSize = size + + DispatchQueue.main.async { + self.parent.invalidateParentCellLayout?(!firstSize) + } + } } // MARK: Variables used for the custom prefetching implementation -- GitLab