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

Falling back to 0 when setting content offset doesn't work when there's contentInset #48

Open
jordanhbuiltbyhq opened this issue Aug 10, 2020 · 0 comments

Comments

@jordanhbuiltbyhq
Copy link

Minor correction. If your collection view has contentInsets for example of UIEdgeInsets(top: 0, left: 24, bottom: 0, right: 24), the contentOffset.x will be -24 initially, so if you fall back to 0 when there's no stored offset that causes it to scroll over inappropriately.

Currently:
tableViewCell.collectionViewOffset = storedOffsets[indexPath.row] ?? 0

This is the fix (but requires the collectionView not be private):
tableViewCell.collectionViewOffset = storedOffsets[indexPath.row] ?? -tableViewCell.collectionView.contentInset.left

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

1 participant