Last active
November 11, 2017 14:44
-
-
Save pgpt10/56268478e4df72dd972498fe7860a3a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let items = coordinator.items | |
if items.count == 1, let item = items.first, let sourceIndexPath = item.sourceIndexPath | |
{ | |
var dIndexPath = destinationIndexPath | |
if dIndexPath.row >= collectionView.numberOfItems(inSection: 0) | |
{ | |
dIndexPath.row = collectionView.numberOfItems(inSection: 0) - 1 | |
} | |
collectionView.performBatchUpdates({ | |
self.items.remove(at: sourceIndexPath.row) | |
self.items.insert(item.dragItem.localObject as! String, at: dIndexPath.row) | |
collectionView.deleteItems(at: [sourceIndexPath]) | |
collectionView.insertItems(at: [dIndexPath]) | |
}) | |
coordinator.drop(item.dragItem, toItemAt: dIndexPath) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment