Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions MagazineLayout/Public/MagazineLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ public final class MagazineLayout: UICollectionViewLayout {
prepareActions.contains(.recreateSectionModels)
{
hasPinnedHeaderOrFooter = false
lastSizedElementMinY = nil
lastSizedElementPreferredHeight = nil
}

// Recreate section models from scratch if necessary
if prepareActions.contains(.recreateSectionModels) {
var sections = [SectionModel]()
for sectionIndex in 0..<currentCollectionView.numberOfSections {
let sectionModel = sectionModelForSection(atIndex: sectionIndex)
sections.append(sectionModel)
}

modelState.setSections(sections)
}

// Update layout metrics if necessary
Expand Down Expand Up @@ -136,25 +149,6 @@ public final class MagazineLayout: UICollectionViewLayout {
}
}

// Recreate section models from scratch if necessary
if prepareActions.contains(.recreateSectionModels) {
var sections = [SectionModel]()
for sectionIndex in 0..<currentCollectionView.numberOfSections {
let sectionModel = sectionModelForSection(atIndex: sectionIndex)
sections.append(sectionModel)
}

modelState.setSections(sections)
}

if
prepareActions.contains(.recreateSectionModels) ||
prepareActions.contains(.updateLayoutMetrics)
{
lastSizedElementMinY = nil
lastSizedElementPreferredHeight = nil
}

prepareActions = []
}

Expand Down