Skip to content
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

Snapping issues when reloading the tableView #1

Open
sergeysmagleev opened this issue Aug 28, 2018 · 1 comment
Open

Snapping issues when reloading the tableView #1

sergeysmagleev opened this issue Aug 28, 2018 · 1 comment

Comments

@sergeysmagleev
Copy link

sergeysmagleev commented Aug 28, 2018

Hello Simon!
Nice repo, it's working great and I like it.
I've been using the same approach in one of the projects I've been working on and it turns out that there's one problem I'd like to talk to you about. This solution works very well as the tableView is static. However, if you have to reload the tableView at some point during the scrolling animation, it can lead to unexpected visual bugs. In order to reproduce the issue, the following conditions should be met:

  1. The data in the tableView should change (i.e. set a different number of rows)
  2. reloadData should be called during the scrolling animation

As the result, one of the following can happen:

  1. (rare) tableView stops scrolling and its contentOffset is stuck in between the two snapping points;
  2. (common) tableView abruptly jumps back to its previous position or to zero offset

Here it is visualized:
bug 1 bug 2

The obvious solution that comes to mind is to defer the reloading until the moment the scrolling is finished, e.g. call reloadData at scrollViewDidEndDecelerating or scrollViewDidEndScrollingAnimation, but I've tried this and it still won't work.

I would like to know if you have any ideas on this topic.

Cheers!

@skagedal
Copy link
Owner

skagedal commented Sep 6, 2018

Hey, thanks a lot for this well written issue! Sorry for not getting back sooner. I unfortunately don't have any suggestions at this time. In the app where I used this technique, we had no need to reload the data. The only idea I can think of is what you already wrote, to wait for did end decelerating or similar. Weird that it doesn't work.

I hope to get around writing a follow-up blog post at some point and mention problems with this approach, I'll be sure to mention this then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants