open func scrollViewDidScroll(_ scrollView: UIScrollView) {
var index = Float(scrollView.contentOffset.x * 1.0 / scrollView.frame.size.width)
index = index.isNaN ? 0 : index
if index < 0.25 {
collectionView.scrollToItem(at: IndexPath(item: data.count, section: 0), at: [.top, .left], animated: false)
} else if index >= Float(data.count + 1) {
collectionView.scrollToItem(at: IndexPath(item: 1, section: 0), at: [.top, .left], animated: false)
}
let page = transferIndex(Int(index))
scrollToPage(page)
calculateParallax()
}
https://hub.fastgit.org/vlondon/VMScrollView
网友评论