marcosgriselli / ViewAnimator

ViewAnimator brings your UI to life with just one line
MIT License
7.3k stars 488 forks source link

Wrong animation in UICollectionView with 2 or more columns in vertical flow #44

Closed dillidon closed 6 years ago

dillidon commented 6 years ago

Instead of

private func indexPathFor(cell: UICollectionViewCell) -> Int {
        return indexPath(for: cell)?.item ?? -1
}

public var views: [UIView] {
        let items = visibleCells
        return items.sorted(by: { indexPathFor(cell: $1) > indexPathFor(cell: $0) })
}

better to use:

public var views: [UIView] {
        return indexPathsForVisibleItems.sorted().compactMap { cellForItem(at: $0) }
}
marcosgriselli commented 6 years ago

Good catch, I'll implement it shortly. Or do you want to send a PR @dillidon?

marcosgriselli commented 6 years ago

Implemented

Thanks @dillidon !

view_animator