lxcid / LXReorderableCollectionViewFlowLayout

Extends `UICollectionViewFlowLayout` to support reordering of cells. Similar to long press and pan on books in iBook.
http://lxcid.com/
MIT License
1.86k stars 328 forks source link

Add delegate methods for controlling visual changes and movement of the ... #60

Closed jeffdav closed 7 years ago

jeffdav commented 10 years ago

...current dragging item.

This adds these delegate methods (all optional):

// Called as dragging starts from animation block to allow custom visual adjustments to the view.
- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout adjustCurrentViewForDragAnimated:(UIView*)currentView;

// Called when the draggable view moves, giving the delegate a chance to control how it has moved.  Useful for restricting movement to a single direction or constraining it to a specific boundary.
- (CGPoint)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout adjustTranslation:(CGPoint)translation forDragOfCurrentView:(UIView*)currentView;

// Called as dragging ends from animation block to allow reversing the animations applied when dragging started.
- (void)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout adjustCurrentViewForDropAnimated:(UIView*)currentView;

Not implementing any of these methods provides the default behavior as it is prior to this change.

jeffdav commented 10 years ago

If you don't want to take this, just let me know. Or if you'd prefer I do it in a different way. I tried to make the minimum changes to enable what I needed to do, and to follow existing coding practices in the project. I also updated the sample project with example usage behind an #ifdef guard.

dillan commented 10 years ago

Nice work Jeff! I hope this gets merged in soon.

jeffdav commented 7 years ago

Well nobody seems to care, so PEACE OUT.