Created
March 15, 2018 07:24
-
-
Save pgpt10/a0e0fa77a56a5bbd75e21d62007beeb0 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 | |
var dIndexPath = destinationIndexPath | |
if dIndexPath.row >= collectionView.numberOfItems(inSection: 0) | |
{ | |
dIndexPath.row = collectionView.numberOfItems(inSection: 0) - 1 | |
} | |
var sourceIndexPaths = [IndexPath]() | |
var destinationIndexPaths = [IndexPath]() | |
for item in items | |
{ | |
if let sourceIndexPath = item.sourceIndexPath | |
{ | |
sourceIndexPaths.append(sourceIndexPath) | |
destinationIndexPaths.append(dIndexPath) | |
self.items2.remove(at: sourceIndexPath.row) | |
self.items2.insert(item.dragItem.localObject as! String, at: dIndexPath.row) | |
dIndexPath = IndexPath(row: dIndexPath.row + 1, section: 0) | |
} | |
} | |
collectionView.performBatchUpdates({ | |
if collectionView === self.collectionView2 | |
{ | |
collectionView.deleteItems(at: sourceIndexPaths) | |
collectionView.insertItems(at: destinationIndexPaths) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment