Add GMGridViewDidScroll, Geometry and pageForContentOffset #22

wants to merge 14 commits into from

2 participants


After pulling the latest from gmoledina/GMGridView I added a few small features that I needed to complete the picture for invi. I think they can be useful in a broader scope.
Please note that the list of commits (12) looks scarry, but most of them are just leftovers from previously non-pulled commits. There are only two interesting commits,

rantav added some commits Nov 16, 2011
@rantav rantav Add pagingEnabled to the grid. It simply delegates the property back …
…to the undelying scrollView
@rantav rantav Fix name of isPagingEnabled to pagingEnabled. Old java habits... d58ccf1
@rantav rantav Implement GMGridViewLayoutHorizontalPagedLtr. a layout for paged hori…
…zontal scroll where items in each page flow from top-left to bottom-right
@rantav rantav Add convertScrolledPoint and convertScrolledRect so users of GMGridVi…
…ew are able to get the position of a scrolled element
@rantav rantav Add 'build' to gitignore 53f7a0e
@rantav rantav Add support for better programatic scroll control.
Expose the contentOffset
Allow scrolling to a particular point (and not only to a particular item)
Add more page queries to the GMGridViewLayoutHorizontalPagedLtrStrategy
... it's all part of the same scheme...
@rantav rantav Add GMGridViewDidScroll so that users know when GMScrollView is scrol…

Looks good ! I'll check it tomorrow and merge it.


Scrolling to a particular point will be weird when paging is enabled

OK, this commit has two different things even though in my mind they are related.
We have the two geometry methods:

  • (CGPoint)originForItemAtColumn:(NSInteger)column row:(NSInteger)row page:(NSInteger)page;
  • (CGPoint)originForPage:(NSUInteger)page;

They are useful to know the physical location on the screen a certain item in a page (I use it to 'fly' things away from the grid off to another UIView in an animation when the user touches them)

The second thing is

  • (void)setContentOffset:(CGPoint)offset animated:(BOOL)animated;

Well, I have a paging control that I use to scroll b/w pages. So I use a combination of originForPage and setContentOffset.
I see why this breaks encapsulation and I'm open for suggestions... the goal is to allow an external page control to slide switch pages in the grid.

As a matter of fact when I come to think of it, regarding setContentOffset and pagingEnabled - this is consistent with how UIScrollView behaves. Event in UIScrollView it's possible to programmatically scroll to any point in the scroll view even though the scroll view is paged. So although I agree with you that this is breaking encapsulation to some degree, at least we didn't break it first and we're consistent with apple model ;)


I agree.
I'll add this on my next update when I'll add an API to allow having a pageControl (so knowing when the page changed).


Is it better to have just one property that controls both horizontal and vertical scroll indicator ?
As we never have both of them visible at the same time anyway.

Alright! I've pulled your code on my local repo. It will be part of the next release.

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