Skip to content

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

@jordanhbuiltbyhq

Description

@jordanhbuiltbyhq

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions