KelvinJin / AnimatedCollectionViewLayout

A UICollectionViewLayout subclass that adds custom transitions/animations to the UICollectionView without effecting your existing code.
MIT License
4.75k stars 351 forks source link

Scroll like animation on the click of Button #30

Open madBureaToT opened 7 years ago

madBureaToT commented 7 years ago

hey! well this works well while we have UICollectionViewCtr when we try to Customize it to ViewController By just setting flowLayout of CollectionView.

Now i have left and right button and i want the same Procedure of scroll animation on the click of these two button Action.

if any one have performed this then please help.

nohraay commented 7 years ago

var nextPage:Int = 0

@objc func clickFn(sender:UIButton){ print(nextPage) print(vcs.count)

    if(nextPage == (vcs.count-1)){
        return
    }
    nextPage += 1
    let nextItem = NSIndexPath(row: nextPage, section: 0)
    collectionView?.scrollToItem(at: nextItem as IndexPath, at: .centeredHorizontally, animated: true)
}
yonlau commented 4 years ago

ScrollToItem didn't work. Any one can help?

updev0612 commented 3 years ago

me too. is there any update?

updev0612 commented 3 years ago

please diable pagination property

soring323 commented 3 years ago

solution is simple. collectionView.collectionViewLayout.invalidateLayout() collectionView.scrollToItem(at: index, at: .centeredHorizontally, animated: false) This is working well.