MichiganLabs / AnimatingTableViewHeader

A Swift project explaining how to animate a header above a UITableView
164 stars 35 forks source link

Header late to expand upon scroll up when table view has bottom layout margins or content inset #8

Open tfe opened 3 years ago

tfe commented 3 years ago

Thanks so much for this code and blog post; so useful!

I noticed an odd behavior where when I'd scroll up from the bottom, the header would be late to un-collapse... I'd have to get a couple cells up from the bottom before it started to un-collapse.

In my case I'm using this technique on a collection view appearing inside a UITabBarController, where the collection view scrolls under the bottom bar.

It occurred to me the amount I was needing to scroll up before triggering the uncollapse was roughly the height of the bottom bar. I realized that the calculation of absoluteBottom probably needs to take this extra space into account.

After accounting for the layout margins (and content inset, same issue) in the absoluteBottom calculation, the un-collapse is now pixel-perfect!

I'll have a PR for you in a second to account for it on this project too. But I wanted to document this in an issue in case someone else was running into the same problem.