So I'm panning cells in a collection view. The cells are wiggling. I'm using following code to re-order the cells in my dataSet. Everything works out. The only problem I have is that the panned cell sometimes stops wiggling. I noticed this happens when I pan too fast, just throwing it to another place. I looked on the internet. Some people advise using invalidatelayout(). Unfortunately this isn't helping. Does anyone know what could help? Tx.
Code:
func panningMediaInMediaCollectionView(gesture: UIPanGestureRecognizer) {
switch(gesture.state){
case .Began:
guard let selectedIndexPath = self.mediaCollectionView.indexPathForItemAtPoint(gesture.locationInView(self.mediaCollectionView)) else {break}
self.mediaCollectionView.beginInteractiveMovementForItemAtIndexPath(selectedIndexPath)
case .Changed:
self.mediaCollectionView.updateInteractiveMovementTargetPosition(gesture.locationInView(self.mediaCollectionView))
case .Cancelled:
self.mediaCollectionView.cancelInteractiveMovement()
case .Ended:
self.mediaCollectionView.endInteractiveMovement()
self.mediaCollectionView.collectionViewLayout.invalidateLayout()
default:
self.mediaCollectionView.cancelInteractiveMovement()
}
}