Closed ElSifi closed 4 years ago
I use this way to find the current focus index for now. just add this code in scrollViewWillEndDragging
if let cell = self.collectionView.collectionViewLayout.layoutAttributesForElements(in: CGRect(x: targetContentOffset.move().x, y: targetContentOffset.move().y, width: self.collectionView.frame.size.width, height: self.collectionView.frame.size.height)) {
if cell.count == 3 { // get middle index
print(cell[1].indexPath.row)
} else if cell.count == 2 {
if self.MSPeekCollectionBehavior.cellPeekWidth == cell[0].frame.origin.x {
// first index
print(cell[0].indexPath.row)
} else {
// last index
print(cell[1].indexPath.row)
}
} else {
}
}
Thanks @magicspring
I've already fixed it using a similar approach 👌
Hello @Badi3 and @magicspring ! So sorry for the late reply, I've now pushed a change to the library 3.1.1
that makes it easier to get the current index:
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
print(behavior.currentIndex)
}
Have a great day!
Is MSPeekImplementationDelegate deprecated in the latest versions? If so, how to get the current active index?
Thanks.