Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
5020
Deceleration On Flow's Grid
posted

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.

Parents
  • 40030
    Offline posted

    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

Reply Children
No Data