AnimatedCollectionViewLayout icon indicating copy to clipboard operation
AnimatedCollectionViewLayout copied to clipboard

On vertical scroll with sections, unexpected behaviour. Cells appear in front of others

Open Johnathan-Aretos opened this issue 5 years ago • 0 comments

When sections are being used it breaks the logic

attributes.zIndex = attributes.indexPath.row -> PageAttributeAnimator.swift

Given a zIndex will determine depth when using indexPath values e.g [0,1], sections, row respectively. We run into issues when the section resets.

I don't know of a cleaner solution, but what I've been using at the moment is

var section = attributes.indexPath.section
var numItems = 0

while section >= 0 {
    numItems += collectionView.numberOfItems(inSection: section)
    section -= 1

attributes.zIndex = attributes.indexPath.row + numItems

Which seems to be doing the trick, my run into performance issues when using larger data sets. A more elegant solution will be to use visible cells and work out within the two cells an appropriate zIndex.

Happy for suggestions to make a PR

Johnathan-Aretos avatar Dec 25 '20 22:12 Johnathan-Aretos