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

Add support for items order by zIndex #48

Open
yossiavramov opened this issue Jun 11, 2019 · 2 comments
Open

Add support for items order by zIndex #48

yossiavramov opened this issue Jun 11, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@yossiavramov
Copy link

UICollectionViewLayout supports the ability to order its elements (cells, supplementary views & decoration views) not only by their IndexPath, so items with small IndexPath will be in the collectionView subviews' stack in front of item with bigger IndexPath. This is required, for example, if you want to have an animation on a cell's content which will hover above all other cells.

It'd be great if MagazineLayout will support changing item's zIndex.

I can implement it & make a pull request. I think that the best place to get this data is part of the delegate call for 'MagazineLayoutItemSizeMode' (maybe we need to change its name to MagazineLayoutItemSizeAndOrderMode)

@bryankeller bryankeller self-assigned this Jul 16, 2019
@bryankeller bryankeller added the enhancement New feature or request label Jul 16, 2019
@bryankeller
Copy link
Contributor

@yossiavramov you'd like the ability to change the z index of an arbitrary item? Is your use case just to have the cell "in front" during an animation? I'm trying to understand the use case better.

I don't love the idea of needing to specify a z-index for every item in the delegate. We could provide some sensible defaults, but I feel like this use case might be too niche to incorporate into the layout delegate.

I could see an argument being made for MagazineLayout being an open class. If you could subclass MagazineLayout, you could change layout attributes as you see fit.

Another possibility is providing a way to modify layout attributes without subclassing. I think this would be preferable, as subclassing collection view layouts is incredibly error prone (so many functions that can be overwritten that will mess things up).

@yossiavramov
Copy link
Author

In my use case, I have a cell that contains draggable views. I want those views to be on top of all other cells. To achieve this, I need the cell that contains those draggable views to be the top most cell in the views hierarchy.

I forked MagazineLayout & added support for this: yossiavramov@d542a95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants