From 1f3e7c4a590dca3e6084a71017b171f3114fea0f Mon Sep 17 00:00:00 2001 From: Mikko Date: Thu, 26 Feb 2015 23:12:22 +0000 Subject: [PATCH] Separate extension points for accessing currentView while dragging --- .../LXReorderableCollectionViewFlowLayout.h | 2 ++ .../LXReorderableCollectionViewFlowLayout.m | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.h b/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.h index 76617f4..f13a227 100755 --- a/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.h +++ b/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.h @@ -35,7 +35,9 @@ - (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout willBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath; - (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout didBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath; +- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout didBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath currentlyDraggedView:(UIView *)currentlyDraggedView; - (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout willEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath; +- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout willEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath currentlyDraggedView:(UIView *)currentlyDraggedView; - (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout didEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath; @end \ No newline at end of file diff --git a/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m b/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m index 9688aad..efb6b09 100755 --- a/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m +++ b/LXReorderableCollectionViewFlowLayout/LXReorderableCollectionViewFlowLayout.m @@ -352,6 +352,9 @@ - (void)handleLongPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer if ([strongSelf.delegate respondsToSelector:@selector(collectionView:layout:didBeginDraggingItemAtIndexPath:)]) { [strongSelf.delegate collectionView:strongSelf.collectionView layout:strongSelf didBeginDraggingItemAtIndexPath:strongSelf.selectedItemIndexPath]; } + if ([strongSelf.delegate respondsToSelector:@selector(collectionView:layout:didBeginDraggingItemAtIndexPath:currentlyDraggedView:)]) { + [strongSelf.delegate collectionView:strongSelf.collectionView layout:strongSelf didBeginDraggingItemAtIndexPath:strongSelf.selectedItemIndexPath currentlyDraggedView:strongSelf.currentView]; + } } }]; @@ -365,6 +368,9 @@ - (void)handleLongPressGesture:(UILongPressGestureRecognizer *)gestureRecognizer if ([self.delegate respondsToSelector:@selector(collectionView:layout:willEndDraggingItemAtIndexPath:)]) { [self.delegate collectionView:self.collectionView layout:self willEndDraggingItemAtIndexPath:currentIndexPath]; } + if ([self.delegate respondsToSelector:@selector(collectionView:layout:willEndDraggingItemAtIndexPath:currentlyDraggedView:)]) { + [self.delegate collectionView:self.collectionView layout:self willEndDraggingItemAtIndexPath:currentIndexPath currentlyDraggedView:self.currentView]; + } self.selectedItemIndexPath = nil; self.currentViewCenter = CGPointZero;