'How to Auto Scroll with Compositional Collection View?

enter image description here

I use Compositional CollectionView to create collectionview with 2 sections. The first section is Horizontal Section as the picture. 1 Group has 3 items ( 3 cells). I want to make auto-scroll for this. Please, Anyone help me. Thank you so much



Solution 1:[1]

I have a similar UI to yours, It's an infinite auto-scrolling collection view using compositional layout. You could check My Demo Project for reference.

When you use Compositional Layout to set up collection view, scrollViewDidScroll(_:) and scrollViewDidEndDecelerating(_:) won't be fired. So we need to use

layout.visibleItemsInvalidationHandler = {
  visibleItems, point, environment in
  // Config auto scroll here 
}

And remember to invalidate timer when user tap the collection view cell. Please see detailed code in the above link.

Hope this help :)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tyler2P