Fix drag and drop target bugs

This commit is contained in:
Maurice Parker
2019-11-21 13:22:33 -06:00
parent 7243e0e07b
commit 150e50082c
2 changed files with 46 additions and 26 deletions

View File

@@ -353,13 +353,11 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
sortedNodes.remove(at: index)
let movementAdjustment = sourceIndexPath < destIndexPath ? 1 : 0
let adjustedIndex = index - movementAdjustment
if adjustedIndex >= sortedNodes.count {
if index >= sortedNodes.count {
let lastSortedIndexPath = dataSource.indexPath(for: sortedNodes[sortedNodes.count - 1])!
return IndexPath(row: lastSortedIndexPath.row + 1, section: lastSortedIndexPath.section)
} else {
return dataSource.indexPath(for: sortedNodes[adjustedIndex])!
return dataSource.indexPath(for: sortedNodes[index])!
}
}