Skip to content

own2pwn/EPCardZoomLayout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

EPCardZoomLayout

Demo1 Demo2

Setup

  1. Instantiate EPInfiniteController of your ModelType
private let ic = EPInfiniteController<YourModel>()
  1. Setup Infinite Behaviour
private func setupInfiniteScrolling() {
        // `collectionView` and `layout` Will be used to
        // Calculate Scroll Points
        
        ic.setCollectionView(collectionView)
        ic.scrollCoordinator.setLayout(cellSize: CUI.Item.cellSize, cellSpacing: CUI.Item.cellSpacing)
        
        // Will be used for animation
        ic.animator.setMinScale(CUI.Item.cellScale)
    }
  1. Update InfiniteController's datasource
private func fetchModel() {
        let fetched = YourModel()
        ic.dataProvider.update(with: fetched)
    }
  1. Update container's center after view ended layout
override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        // To appear nicely
        ic.scrollToCenter(animated: false)
        
        // To recalculate scroll points
        ic.scrollCoordinator.updateContainerCenter(collectionView.center)
    }
  1. Coordinate scrolling and animations
 func scrollViewDidScroll(_ scrollView: UIScrollView) {
        let visibleCells = collectionView.visibleCells
        ic.animator.transform(visibleCells)
        ic.scrollCoordinator.onScroll(scrollView)
    }
  1. You're good to go!