Permalink
Browse files

More table drag-to-reorder updates

  • Loading branch information...
1 parent 96b764f commit 6301a7f4e8e510dd58ac8d3bc519a7501ca0ca02 Brian William Wolter committed Aug 3, 2011
Showing with 13 additions and 3 deletions.
  1. +13 −3 lib/UIKit/TUITableView+Cell.m
@@ -104,9 +104,15 @@ -(void)__mouseDraggedCell:(TUITableViewCell *)cell offset:(CGPoint)offset event:
// if we're on a section header (but not the first one, which can't move) we insert after the last index in the
// preceding section
if((sectionIndex = [self indexOfSectionWithHeaderAtPoint:CGPointMake(location.x, location.y + visible.origin.y)]) > 0){
- NSInteger previousSectionIndex = sectionIndex - 1;
- currentPath = [TUIFastIndexPath indexPathForRow:[self numberOfRowsInSection:previousSectionIndex] - 1 inSection:previousSectionIndex];
- insertMethod = TUITableViewInsertionMethodAfterIndex;
+ if(sectionIndex <= cell.indexPath.section){
+ NSInteger targetSectionIndex = sectionIndex - 1;
+ currentPath = [TUIFastIndexPath indexPathForRow:[self numberOfRowsInSection:targetSectionIndex] - 1 inSection:targetSectionIndex];
+ insertMethod = TUITableViewInsertionMethodAfterIndex;
+ }else{
+ NSInteger targetSectionIndex = sectionIndex;
+ currentPath = [TUIFastIndexPath indexPathForRow:0 inSection:targetSectionIndex];
+ insertMethod = TUITableViewInsertionMethodBeforeIndex;
+ }
}
}
@@ -191,6 +197,10 @@ -(void)__mouseDraggedCell:(TUITableViewCell *)cell offset:(CGPoint)offset event:
// the visited index path is the current index path and the insertion method is "after";
// leave the cell where it is, the section header should shift out of the way instead
target = frame;
+ }else if([indexPath isEqual:currentPath] && insertMethod == TUITableViewInsertionMethodBeforeIndex){
+ // the visited index path is the current index path and the insertion method is "before";
+ // leave the cell where it is, the section header should shift out of the way instead
+ target = frame;
}else if([indexPath compare:currentPath] != NSOrderedAscending && [indexPath compare:cell.indexPath] == NSOrderedAscending){
// the visited index path is above the origin and below the current index path;
// shift the cell down by the height of the dragged cell

0 comments on commit 6301a7f

Please sign in to comment.