-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animating cell size change don't-know-how #459
Comments
@iostriz thanks for the sample project! TIL that you can animate The reason that this doesn't work is b/c IGListKit asynchronously coalesces updates. That is, it collects multiple batch updates during the runloop and unloads them at once. So the call to We might be able to do something about this, though. I wonder if we can get the currently stacked animations when batch updates is called, store them somewhere, then hand them to the Tbh I have no idea if Time to dig into some Core Animation... |
Hi Ryan, thanks for taking a peek into project. |
@iostriz @rnystrom I did some digging on your sample code:
[UIView animateWithDuration:0.35 delay:0.0 usingSpringWithDamping:0.7 initialSpringVelocity:0.0 options:0
animations:^{
[_collectionView performBatchUpdates:nil completion:nil];
} completion:nil]; works like magic is that, since the update block is So we might be able to bring your springy animation back once we add #360. |
@iostriz ok I did more digging on your setup and got it working a little better, but its not perfect. A couple recommendations:
So what I did was update - (void)didSelectItemAtIndex:(NSInteger)index
{
NSMutableIndexSet *indexes = [NSMutableIndexSet indexSetWithIndex:_model.selectedIndex];
[indexes addIndex:index];
_model.selectedIndex = index;
[UIView
animateWithDuration:0.35
delay:0.0
usingSpringWithDamping:0.7
initialSpringVelocity:0.0
options:0
animations:^{
[self.collectionContext reloadInSectionController:self
atIndexes:indexes];
}
completion:nil];
} Like I said its not perfect, sometimes the animation doesn't spring and just fades, which is boring. I've honestly never seen the spring animations work like this, so its pretty cool! I wonder if we should add another This made me realize that the reload methods are worth keeping, which is contrary to #392. I think that delete+insert+move have to be done in a batch update, but reloads are valid outside of that scope, especially for stuff like this. This issue was really valuable! |
@rnystrom Right, animation over layout invalidation doesn't work (cells spring just fine, but there are some random white views flashing in the background). Don't know why 🤔.
This would be great! Actually, I think we can allow sending in an update block as well. So that we can perform some layout-only updates. Something like: [self.collectionview performBatchUpdates:^{
[self.collectionview.collectionViewLayout invalidateLayout];
[self.collectionview setCollectionViewLayout: newLayout animated:YES];
} completion:^(BOOL finished) {
...
}]; |
@rnystrom Glad that I have a "valuable issue"... Maybe you can buy me a sandwich? :-) |
@zhubofei good point. Reminds me that the layout that we're using in #450 caches values, so you can't just change w/e is returned in the size methods, you have to invalidate the layout. Maybe the layout methods need to be smarter, something like: - (void)invalidateLayoutForSectionController:(IGListSectionController<IGListSectionType> *)sectionController
indexes:(NSIndexSet *)indexes
animated:(BOOL)animated; And the implementation inside - (void)invalidateLayoutForSectionController:(IGListSectionController<IGListSectionType> *)sectionController
indexes:(NSIndexSet *)indexes
animated:(BOOL)animated {
NSArray<NSIndexPath *> paths = // create paths from SC + indexes
UICollectionViewLayoutInvalidationContext *context = // new from layout
[context invalidateItemsAtIndexPaths:paths];
void (^updates)() = ^{
[self.collectionView.collectionViewLayout invalidateLayoutWithContext:context];
};
if (animated) {
[self.collectionView performBatchUpdates:updates completion:nil];
} else {
updates();
}
} Some thoughts:
|
@rnystrom Glad you find this valuable. Maybe you can buy me a sandwich! :-) |
probably not 😂. |
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 #499 Reviewed By: jessesquires Differential Revision: D4590274 Pulled By: rnystrom fbshipit-source-id: f87235be4e6c024bf979b831a8938be68895e011
Like mentioned in roberthein/BouncyLayout#6 I have trouble using this new feature with a custom It looks like a cache problem in the layout, but I don't see any cache mecanism in BouncyLayout. Please find attach my example : Maybe I'm doing something wrong. I start to wonder if a " |
I progressed a bit, I found a way to do it but it's a bit dirty (see delegate method New code : |
@LivioGama do you mind opening a new issue to track this? |
Hi IGListGang,
I'm facing one odd problem - but I admit it is the lack of my experience with IGListKit. So please, if you find it interesting enough, answer it, pretty please. I apologise if you had similar question, I glanced all of them without success.
I must have a recipients selector, a horizontal collection view with circles representing contacts and with initials inside. When user clicks on one, it should expand a bit and display some additional information.
Like this:
When user clicks on the cell, it should glide nicely into expanded position and vice versa; preferably with some custom springy-thingy dance. You can take a look into "Classic" approach in provided project, quite straight-forward, less then one screen example...
Then I said, ok let's
IGListify
this. I have decided to go with single section controller with multiple items inside, because it feels natural to putNSInteger selectedIndex;
that will keep information about which model is in selected state, inside section controller.But, animation was jerky and eye-poking.
Then I have created the same example with one item per section controller (I saw that almost all provided samples in your project use one item per controller), and with some mumbo-jumbo-selectedIndex-delegate-weak-reference, it worked. ...But with the same result...
Here I have provided small project that runs all three examples. Again, please, show me the right path, it feels like it should work, only I don't know where to put this animating thing and how.... Also if you have a better design in mind, I would really appreciate it. Please remove
performBitchUpdates
if possible. (:-) Hi Ryan!)RecipientsViewController.zip
br
IGor
New issue checklist
README
and documentationGeneral information
IGListKit
version: HEADThe text was updated successfully, but these errors were encountered: