Better scroll animation when item expands (fixes #90 too) #102
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This improves the scroll animation which occurs after an item has been expanded a lot, imho. Not only it solves #90, but also manage the special case in which the item is taller than the container ListView. In particular, after the item expands, it makes some computation and then:
I made this edit particularly because of case 2: I'm using items that, when expanded, can be really tall. Not sure if other cases were already covered, but I'm quite sure I experienced issues also when items were smaller.
I tested it on the most recent API and on API 8 and 10. It works as expected in all cases. I made the PR on top of your last commit and in a separate brach, so you can merge with no problems.
Further improvement to make it perfect could be starting the scroll animation together with the expand animation (i.e. in the
onAnimationStart
callback instead ofonAnimationEnd
). Unfortunately this requires not only to get the end height in advance (from theExpandCollapseAnimation
instance for example), but also to take account of the old expanded item which, in the meantime, could be collapsing. I'll work on it if I'll have some spare time, it's not critical for me atm.