Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Size of Visible Cell Node Does Not Update when Cell Size Changes #2659

@iwheelbuy

Description

@iwheelbuy

I have a custom layout which generate frames of different sizes!

2016-11-26 0 27 02

2016-11-26 0 27 24

2016-11-26 0 18 06

2016-11-26 0 25 38

That is the example collection view that has 1, 2, 3, 4... objects at start.
We can also add an object with (+) button. We add an object and update our collection with animation through batch update.

If we add one more object when there is only one object in collection
2016-11-26 0 27 02
we expect the first cell to shrink from big size to small size. The new big one will go to a place where our previous big cell was situated. The shrinked object will move to a new place
2016-11-26 0 27 24
But the previous one doesn't change its frame and we see
2016-11-26 0 37 40

I have implemented the ASCollectionViewLayoutInspecting protocol so I can see all the generated sizes.

extension SquareMosaicLayout: ASCollectionViewLayoutInspecting {
    
    func collectionView(_ collectionView: ASCollectionView, constrainedSizeForNodeAt indexPath: IndexPath) -> ASSizeRange {
        guard let layout = collectionView.collectionViewLayout as? SquareMosaicLayout else {
            return ASSizeRange(min: .zero, max: .zero)
        }
        debugPrint("--->", layout.size(indexPath))
        return ASSizeRange(min: .zero, max: layout.size(indexPath))
    }
    
    func scrollableDirections() -> ASScrollDirection {
        return ASScrollDirectionVerticalDirections
    }
}

But it turned out that it asks for the size only when the cell was first shown. So it doesn't ask for the updated size of the cell so that the cell can be shrinked...

AsyncDisplayKit '2.0-beta.2'
Sample Project: https://github.com/iwheelbuy/layout

P.S. I have a feeling that i miss something... Please, help me to figure it out

P.S. If you use TripleSquareMosaicPattern instead of SnakeSquareMosaicPattern in project it will show that nodes of same size do work correctly during animated updates

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions