-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Drop cell into another cell #56
Comments
That's a good question. I think you'd have to make some substantial changes to the reordering logic. Currently the code is only looking for a new "destination row" as you drag cells around, but to allow hovering, it would have to also check for a "hover" state and update things accordingly. Probably would need to add something like To detect the hover state, it might be as simple as adding a check to Those delegate methods look like a good place to start. You might also want one that fires when a cell is hovered/un-hovered, so the cell can be visually highlighted in some way. |
Thanks! I'll definitely need folders at some point, and I don't see a better option than extending this library so far. My high level understanding is that there is a blank cell below the hovered cell that is switching depending on where the dragged cell is located. I might be wrong on that tho. If that is the case, I assume that I could call my delegate function for a destination row: canDragHoverOverIndexPath - and if it returns true, I'd just delete the blank cell from the table and store the blank cell's reference in a local class. Then I'd set isHighlighted = true on the destination row. This could be problematic however if deleting the blank cell scrolls the tableView, but I'm getting ahead of myself. Anyway, thanks again for your thoughts on this. I think they will make more sense once I do a side-by-side comparison of the code with your notes. |
You're right, there is a blank spacer cell inserted in the tableview beneath the location you're dragging. I don't think you'd want to remove that spacer when hovering over another row though. That would cause your content to keep shifting up and down as you dragged cells around. As an example, check out the behavior when reordering apps on the iOS home screen. When hovering one app over another to create a folder, there's still a blank space where the original app used to be. |
Good feedback. I'll implement it this way. Thanks! |
No problem! Let me know if you're able to get it working. |
Hello again! At some point I'll be putting folders into my table - any suggestions for dragging a cell onto another cell with existing functionality, or places to start to make this possible in your library would be helpful.
I figure additional delegate methods (or a separate delegate) might look something like:
func canDragHoverOverIndexPath(_ indexPath : IndexPath) {
// return true if folder / hoverable element, false otherwise to reorder. Defaults to false if the user doesn't extend/override it.
}
func didDropDragItemIntoIndexPath(_ indexPath: IndexPath, fromSourceIndex sourceIndexPath : IndexPath) {
// delete the source index path and update data. Default to false if the user doesn't extend/override it.
}
The text was updated successfully, but these errors were encountered: