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

Fix performance issue with updating content offset #106

Merged
merged 2 commits into from
Jan 5, 2018

Conversation

rechsteiner
Copy link
Owner

When updating the content offset while scrolling relatively fast the
menu items would sometimes lag behind. This was mostly visible in
performance heavy situations, like when using the width delegate
alongside some resource heavy view controllers. Moving the content
offset invalidation out of the collection view layout fixes this issue.

With these changes, the invalidation context is only used to update
the layout attributes, and not to calculate the distance to the next
item or to update the content offset. The PagingViewController is now
responsible for updating the content offset, while the distance
calculation is moved into its own separate struct. This also makes the
distance calculation much easier to test.

When updating the content offset while scrolling relatively fast the
menu items would sometimes lag behind. This was mostly visible in
performance heavy situations, like when using the width delegate
alongside some resource heavy view controllers. Moving the content
offset invalidation out of the collection view layout fixes this issue.

With these changes, the invalidation context is only used to update
the layout attributes, and not to calculate the distance to the next
item or to update the content offset. The PagingViewController is now
responsible for updating the content offset, while the distance
calculation is moved into its own separate struct. This also makes the
distance calculation much easier to test.
Storing the distance and initial content offset in the PagingState is
more reliable as the state will then contain all the details needed to
update the content offset, instead of relying on a separate property
that have to be updated whenever the state changes.
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

Successfully merging this pull request may close these issues.

1 participant