sobri909 / MGBoxKit

Simple, quick iOS tables, grids, and more
Other
1.79k stars 283 forks source link

Animation quirk when reducing height of a row in a table-like layout #134

Closed adpalumbo closed 9 years ago

adpalumbo commented 9 years ago

Let's say I have a table-like layout with rows A, B, and C:

A
B
C

When a user taps A, I want to expand that row to show some extra content, and so I adjust the height of box A and call layoutWithDuration:completion: on the container. This yields a beautiful animation and I end up with

A
  aaa
  aaa
B
C

But I can't seem to figure out a supported way to reverse this process. If I just do the opposite of what I did before, and shrink A's height and then call layoutWithDuration:completion:, A shrinks before the animation occurs, so I actually end up with a big gap between A and B:

A

B
C

until B and C gradually slide up over the duration of the animation.

What I'd like is for A to gradually shrink at the exact same pace that B and C raise, just the same as how it gradually expanded as B and C dropped lower.

I'm inclined to think that this isn't a bug in MGBoxKit, but I'd like to know if this is a supported use case and -- if so -- what the best way to pull it off might be.

sobri909 commented 9 years ago

Are you firing off your height change animation at the same time as calling layoutWithDuration:completion:? If you do the height change animation then directly after call the layout method, the two animations should happen in parallel. If that's not happening then there's something weird going on.

adpalumbo commented 9 years ago

D'oh! You're absolutely correct, and of course I wasn't doing that. I fixed it and it works perfectly. Thanks for your time!