It would be nice if the scroll view could be easily configured to decelerate at the boundaries of the flow's internal grid. That way, user scrolls would "snap" to an appropriate place.
Hey Caylan,
We can't really implement this on our end as the IGFlowLayoutView derives from UIScrollView. This means that we can't actually listen for the changes in scroll position, as the only way to know that information is through the control's delegate. If we were to listen to that delegate, and the developer consuming the control wanted to listen to it as well, they'd override us.
However, the code to do it is pretty straightforward, just override the following method:
-(void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
CGFloat blocks = [self numberOfBlocksInViewport:_flowLayoutView].height;
CGFloat blockSize = (int)(_flowLayoutView.frame.size.height/blocks);
CGFloat newPos = targetContentOffset->y;
CGFloat diff = newPos/blockSize;
newPos -= ((diff - (int)diff) * blockSize);
*targetContentOffset = CGPointMake(targetContentOffset->x, newPos);
}
Let me know how that works for you.
-SteveZ
Thanks for the code. I will test this in the coming days.
Works as advertised. Thanks again.