From aee3c9a801fc3f27ec0271f2caf8be2b40b24819 Mon Sep 17 00:00:00 2001 From: Jeremy Rea Date: Sat, 24 Sep 2016 13:32:51 -0400 Subject: [PATCH] Current status before upgrading to Swift 3 syntax --- .../Source/JRLongPressGestureHandler.swift | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/JRLongPressGestureHandler/Source/JRLongPressGestureHandler.swift b/JRLongPressGestureHandler/Source/JRLongPressGestureHandler.swift index 2e3de55..951f056 100644 --- a/JRLongPressGestureHandler/Source/JRLongPressGestureHandler.swift +++ b/JRLongPressGestureHandler/Source/JRLongPressGestureHandler.swift @@ -57,6 +57,28 @@ public class JRLongPressGestureHandler { snapshot?.center = center if cellMoved(sourceIndexPath!, indexPath: indexPath!) { + + print("cell center: ", center.y) + print(tableView.frame.height + tableView.contentOffset.y - 88) + print("--------") + + + // Scrolling + if(center.y > tableView.frame.height + tableView.contentOffset.y - 65 && indexPath!.row + 1 < tableView.numberOfRowsInSection((indexPath?.section)!)) { + indexPath = NSIndexPath(forRow: indexPath!.row + 1, inSection: indexPath!.section) + + UIView.animateWithDuration(0.5, animations: { () -> Void in + tableView.scrollToRowAtIndexPath(indexPath!, atScrollPosition: .Bottom, animated: false) + }) + } else if (center.y - tableView.contentOffset.y < 64 + 65 && indexPath!.row - 1 >= 0) { + // 64 is height of navigation bar + status bar +// indexPath = NSIndexPath(forRow: indexPath!.row - 1, inSection: indexPath!.section) + + UIView.animateWithDuration(0.5, animations: { () -> Void in + tableView.scrollToRowAtIndexPath(indexPath!, atScrollPosition: .Top, animated: false) + }) + } + displaceCellAnimation(tableView, indexPath: indexPath!) }