Skip to content

Commit a7d7eac

Browse files
committed
[RST-27240] Reverts 'Revert cell animation fix (#542)'
1 parent 1aef0f4 commit a7d7eac

5 files changed

Lines changed: 19 additions & 50 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Fixed
44

5+
- Fixed an issue where animations would occur when dequeuing / reusing cells. A layout is now forced without animation before presentation.
6+
57
### Added
68

79
### Removed

Development/Sources/Demos/Demo Screens/AnimatedReuseViewController.swift

Lines changed: 0 additions & 39 deletions
This file was deleted.

Development/Sources/Demos/Demo Screens/CollectionViewAppearance.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ struct Toggle : Element {
270270

271271
config.apply { toggle in
272272
if toggle.isOn != self.isOn {
273-
toggle.setOn(self.isOn, animated: true)
273+
toggle.setOn(self.isOn, animated: UIView.inheritedAnimationDuration > 0.0)
274274
}
275275
toggle.onToggle = self.onToggle
276276
}

Development/Sources/Demos/DemosRootViewController.swift

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ public final class DemosRootViewController : ListViewController
351351
DemoHeader(title: "Other Layouts")
352352
}
353353

354-
Section("testing") { [weak self] in
354+
Section("fuzzing") { [weak self] in
355355

356356
Item(
357357
DemoItem(text: "Fuzz Testing"),
@@ -368,16 +368,8 @@ public final class DemosRootViewController : ListViewController
368368
self?.push(SupplementaryTestingViewController())
369369
}
370370
)
371-
372-
Item(
373-
DemoItem(text: "Verify Reuse Has No Animation"),
374-
selectionStyle: .selectable(),
375-
onSelect : { _ in
376-
self?.push(AnimatedReuseViewController())
377-
}
378-
)
379371
} header: {
380-
DemoHeader(title: "Testing")
372+
DemoHeader(title: "Fuzz Testing")
381373
}
382374

383375
Section("selection-state") {

ListableUI/Sources/ListView/ListView.Delegate.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ extension ListView
147147
item.willDisplay(cell: cell, in: collectionView, for: indexPath)
148148

149149
self.displayedItems[ObjectIdentifier(cell)] = item
150+
151+
UIView.performWithoutAnimation {
152+
/// Force a layout of the cell before it is displayed, so that any implicit animations
153+
/// are avoided. This ensures that cases like toggling a switch on and off are
154+
/// not animated as the cell comes into view.
155+
cell.layoutIfNeeded()
156+
}
150157
}
151158

152159
func collectionView(
@@ -182,6 +189,13 @@ extension ListView
182189
headerFooter.collectionViewWillDisplay(view: container)
183190

184191
self.displayedSupplementaryItems[ObjectIdentifier(container)] = headerFooter
192+
193+
UIView.performWithoutAnimation {
194+
/// Force a layout of the cell before it is displayed, so that any implicit animations
195+
/// are avoided. This ensures that cases like toggling a switch on and off are
196+
/// not animated as the cell comes into view.
197+
container.layoutIfNeeded()
198+
}
185199
}
186200

187201
func collectionView(

0 commit comments

Comments
 (0)