Instagram / IGListKit

A data-driven UICollectionView framework for building fast and flexible lists.
https://instagram.github.io/IGListKit/
MIT License
12.85k stars 1.54k forks source link

section displays under cells that their zIndex are greater than 1000 #1227

Open aelam opened 6 years ago

aelam commented 6 years ago

New issue checklist

General information

Debug information

# Please include debug logs using the following lldb command:
po [IGListDebugger dump]

when there are over 1000 cells, the cells that the indexPaths are greater than 1000 would display over section header for example, In section 0 when indexPath.item == 1000, the zIndex of this cell is 1000, the zIndex of the header is 999, that means header displays under cells

IGListCollectionViewLayout.mm LINE:123

static void adjustZIndexForAttributes(UICollectionViewLayoutAttributes *attributes) {
    const NSInteger maxZIndexPerSection = 1000;
    const NSInteger baseZIndex = attributes.indexPath.section * maxZIndexPerSection;

    switch (attributes.representedElementCategory) {
        case UICollectionElementCategoryCell:
            attributes.zIndex = baseZIndex + attributes.indexPath.item;
            break;
        case UICollectionElementCategorySupplementaryView:
            attributes.zIndex = baseZIndex + maxZIndexPerSection - 1;
            break;
        case UICollectionElementCategoryDecorationView:
            attributes.zIndex = baseZIndex - 1;
            break;
    }
}
richardtop commented 6 years ago

Should be solved by introducing a larger maxIndexPerSection.

aelam commented 6 years ago

@richardtop i think the zIndex of items could not be descended, just set them a same zINDEX. then everyrhing is easier to control

richardtop commented 6 years ago

@aelam It can be descended too. Your idea would work as well. The difference in the zIndex affects appearance only when the two items overlap.

aelam commented 6 years ago

@richardtop As I understand IGListCollectionViewLayout is more powerful than FlowLayout, but it's FlowLayout, I can't image a case that two items overlap.

richardtop commented 6 years ago

@aelam easily, if you consider supplementary & decoration views. E.g. Whole-section shadows.

russelltwarwick commented 5 years ago

Was there any resolution on this?