Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scrollToItemAtIndex issue when using Horizontal AQGridView #88

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

scrollToItemAtIndex issue when using Horizontal AQGridView #88

pip8786 opened this issue Sep 30, 2011 · 0 comments

Comments

@pip8786
Copy link

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
Projects
None yet
Development

No branches or pull requests

1 participant