NSCollectionView performBatchUpdates does not change the animation

When I do the animation individually, everything works fine, but inside the performBatchUpdates block performBatchUpdates change is instantaneous, almost like I called reloadData() . Am I using it correctly?

Working method:

 NSAnimationContext.currentContext().duration = 0.25 indexPathChanges.map({collectionView.animator().moveItemAtIndexPath($0.0, toIndexPath: $0.1)}) 

performBatchUpdates version (instant change - no animation):

 NSAnimationContext.currentContext().duration = 0.25 collectionView.performBatchUpdates( { indexPathChanges.map({self.collectionView.moveItemAtIndexPath($0.0, toIndexPath: $0.1)}) // tried this as well - no luck // indexPathChanges.map({self.collectionView.animator().moveItemAtIndexPath($0.0, toIndexPath: $0.1)}) }, completionHandler: {(finished) in print("Finished: \(finished)") 
+6
source share
1 answer

Try to put it this way:

 collectionView.animator().performBatchUpdates({<your animations>}, completionHandler:{finished in <your completion handler>}) 

In other words, pass it through the animator() proxy.

+7
source

All Articles