Skip to content

Commit

Permalink
Force layout before appear, to avoid animated updates (#505)
Browse files Browse the repository at this point in the history
* Force layout of views before they appear, to avoid animated updates occurring when cells are recycled.
  • Loading branch information
kyleve authored Sep 20, 2023
1 parent 60f5e89 commit ae33952
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fixed a bug that resulted in header/footer views not properly updating, by fixing the underlying tracking of collection view supplementary views.
- Fixed an issue where supplementary views (headers or footers) that contained a first responder would result in the view being duplicated when scrolled off-screen.
- Fixed an issue where animations would occur when dequeuing / reusing cells. A layout is now forced without animation before presentation.

### Added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,15 @@ extension PresentationState
HeaderFooterContentView<Content>(frame: frame)
}

self.applyTo(
view: view,
for: .willDisplay,
with: .init(environment: environment)
)
UIView.performWithoutAnimation {
self.applyTo(
view: view,
for: .willDisplay,
with: .init(environment: environment)
)

view.layoutIfNeeded()
}

return view
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,16 @@ extension PresentationState

let itemState = ListableUI.ItemState(cell: cell, isReordering: false)

self.applyTo(
cell: cell,
itemState: itemState,
reason: .willDisplay,
environment: environment
)
UIView.performWithoutAnimation {
self.applyTo(
cell: cell,
itemState: itemState,
reason: .willDisplay,
environment: environment
)

cell.layoutIfNeeded()
}

return cell
}
Expand Down

0 comments on commit ae33952

Please sign in to comment.