Cyrus
Cyrus

Reputation: 21

How to know that horizontal collectionView section did end decelerating?

I have a vertically scrolling collectionView where sections are scroll horizontally. How to know that section did end decelerating? If I use

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
        
    }

delegate just says me about vertical scrolling.

Upvotes: 2

Views: 652

Answers (1)

Pete Streem
Pete Streem

Reputation: 390

If you are using Compositional Layout, you can achieve this kind of horizontal scroll logic via visibleItemsInvalidationHandler inside NSCollectionLayoutSection.

Like here:

sectionLayout.visibleItemsInvalidationHandler = { [weak self] items, contentOffset, environment in
        // Here you can add some code to handle some kind of logic using contentOffset
    }

Upvotes: 2

Related Questions