scrollToItemAtIndex issue when using Horizontal AQGridView #88

Open
pip8786 opened this Issue Sep 30, 2011 · 0 comments

Comments

Projects
None yet
1 participant

pip8786 commented Sep 30, 2011

The grid view won't scroll to an item that is to the left or right of the visible portion.

Here's a fix I used:

case AQGridViewScrollPositionTop:
if (self.layoutDirection == AQGridViewLayoutDirectionHorizontal) {
targetRect.origin.x = gridRect.origin.x;
} else {
targetRect.origin.y = gridRect.origin.y; // set target y origin to cell's y origin
}
break;

    case AQGridViewScrollPositionMiddle:
        if(self.layoutDirection == AQGridViewLayoutDirectionHorizontal ) {
            targetRect.origin.x = MAX(gridRect.origin.x - (CGFloat)ceilf((targetRect.size.width - gridRect.size.width) * 0.5), 0.0);
        } else {
            targetRect.origin.y = MAX(gridRect.origin.y - (CGFloat)ceilf((targetRect.size.height - gridRect.size.height) * 0.5), 0.0);
        }
        break;

    case AQGridViewScrollPositionBottom:
        if (self.layoutDirection == AQGridViewLayoutDirectionHorizontal) {
            targetRect.origin.x = MAX((CGFloat)floorf(gridRect.origin.x - (targetRect.size.width - gridRect.size.width)), 0.0); 
        } else {
            targetRect.origin.y = MAX((CGFloat)floorf(gridRect.origin.y - (targetRect.size.height - gridRect.size.height)), 0.0);
        }
        break;

stewarthaines added a commit to stewarthaines/AQGridView that referenced this issue Sep 3, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment