-
Notifications
You must be signed in to change notification settings - Fork 85
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
Horizontal grid/property #90
Comments
Yes I had this planned, although I can't give a timeframe for this at the moment. |
Great, which solution do you prefer? If I get some spare time. |
Worked a bit on this, as a new layout. Is that OK with you guys this way? |
I was thinking perhaps the best way to implement this was to add a readonly property onto the base layout class that determines the scroll direction (vertical or horizontal). Then quite a bit of the logic in the grid layout could be reused, although there would have to be quite a bit of conditionalization for the layout direction. Like so: @interface JNWCollectionViewLayout : NSObject
...
@property (nonatomic, assign, readonly) JNWCollectionViewScrollDirection scrollDirection;
...
@end Then layouts can specifically return which scroll direction they support, or alternatively they can override this property making it readwrite if they support both (which the grid layout would). This makes it a bit more generalized for all layouts, instead of making it specifically for the grid layout, since this requires changing behavior on the scroll view itself. |
This is a hard one, because the code for this would be largely similar, but yet different in a lot of places... Even delegate calls like collectionView:heightForHeaderSection: wouldn't make much sense anymore. But then maybe we're not even talking about the same thing, what would be a horizontal grid layout in your mind? Single-row layout, with one item per column, or multiple rows, but limited in height to the visible size? |
That's true, I hadn't thought about that. I was thinking of something more along the lines of having multiple rows by default with the height limited, with an option to restrict the maximum number of rows to effectively allow it to have both behaviors. But yes unfortunately there's a lot of terminology here that doesn't mix well between the different layout directions. I just really don't like code duplication. Also for what it's worth, I'd love to eventually write a fully featured flow layout (like |
OK, so what I worked on so far is something else, more of a "horizontal list view", if you could call it that... I'll sleep on the horizontal grid thingie, maybe there's some way to make it work anyway. |
I wrote a subclass of JNWCollectionViewLayout. It's basically a copy of JNWCollectionViewGridLayout, without the header and footer part. Logic is reversed to be horizontal. Not generic and should only be used with one row. I think the logic for the placement in a generic horizontal layout should be numberOfRows = collectionView.bounds.size.height / itemSize.height;
numberOfColumns = ceil(numberOfItems / numberOfRows); placement of 3 rows and 10 items 1 2 3 4 My implementation only need one row so the default placement behaviour satisfies my needs but the same example using my layout would use a placement layout like this, which I think is wrong. 1 4 7 10 I'll be happy to share it. |
@samirda I'd love to see it! I'm not sure it's something I'd merge as I'm still attempting to go forward with a flow layout, but if you want to publish it as a separate repo (or as a fork if that's how you implemented it) then I'd be happy to take a look. |
Sorry for the delay. https://gist.github.com/samirda/8942538 Logic is reversed to be horizontal. Not generic and should only be used with one row. |
Horizontal grid layout or horizontal property on JNWCollectionViewGridLayout.
The text was updated successfully, but these errors were encountered: