mirror of
https://github.com/tappollo/IGListKit.git
synced 2026-06-20 03:19:00 +08:00
Layout invalidation API
Summary: Adding a new layout-invalidation API, telling the layout object to query and rebuild the layout for all items in the section controller. This works with `UICollectionViewFlowLayout` and should work with other custom layouts (including our own). Issue fixed: #360, #459 - [x] All tests pass. Demo project builds and runs. - [x] I added tests, an experiment, or detailed why my change isn't tested. - [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes. Closes https://github.com/Instagram/IGListKit/pull/499 Reviewed By: jessesquires Differential Revision: D4590274 Pulled By: rnystrom fbshipit-source-id: f87235be4e6c024bf979b831a8938be68895e011
This commit is contained in:
committed by
Facebook Github Bot
parent
2adea72158
commit
6bdcac81d8
@@ -32,7 +32,6 @@ final class ExpandableSectionController: IGListSectionController, IGListSectionT
|
||||
|
||||
func cellForItem(at index: Int) -> UICollectionViewCell {
|
||||
let cell = collectionContext!.dequeueReusableCell(of: LabelCell.self, for: self, at: index) as! LabelCell
|
||||
cell.label.numberOfLines = expanded ? 0 : 1
|
||||
cell.label.text = object
|
||||
return cell
|
||||
}
|
||||
@@ -43,7 +42,14 @@ final class ExpandableSectionController: IGListSectionController, IGListSectionT
|
||||
|
||||
func didSelectItem(at index: Int) {
|
||||
expanded = !expanded
|
||||
collectionContext?.reload(in: self, at: IndexSet(integer: 0))
|
||||
UIView.animate(withDuration: 0.5,
|
||||
delay: 0,
|
||||
usingSpringWithDamping: 0.4,
|
||||
initialSpringVelocity: 0.6,
|
||||
options: [],
|
||||
animations: {
|
||||
self.collectionContext?.invalidateLayout(for: self)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user