marcosgriselli / ViewAnimator

ViewAnimator brings your UI to life with just one line

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Animation does not work for the bottom cells.

alexanderkhitev opened this issue · comments

Hello! There was a problem when using ViewAnimator and UIRefreshControl, that is, if for the first time the animation works as it should, then the second time after the data is reloaded with UIRefreshControl, the bottom three cells appear without animation. Of course, I understand that this is due to the fact that these cells are not visibleCells (at the start of the animation, 12 cells are visible, after the animation 15), but how to solve this problem?

Please see the video https://monosnap.com/file/CNs9V8EKIWbOsuLzXcybqfMRDb5jYp

Specifications

  • Version: 11.1.1
  • Platform: iOS

Update: At the moment I made a hack that I increase the CollectionView height to a value that helps to animate the lower row of cells, but there may be options to do it better.

@alexanderkhitev did you came up with a more complete solution? I'll be looking into this next.

@marcosgriselli sorry for late response.
I did not come up with a new solution, since I no longer work on that project.

0ef02e4 adds the possibility of creating a straightforward fix for this kind of issues. We can now pass in the views we want to animate so we can get the visible cells and append the cell after the last visible one doing something like:

var cells = tableView.visibleCells
// Check if the refresh control is refreshing.
if let lastCell = visibleCells.last, let nextToLastIndexPath = collectionView.indexPath(for: lastCell) {
    if let nextToLastCell = collectionView.cellForItem(at: nextToLastIndexPath) {
        cells.append(nextToLastCell)
    }
}

UIView.animate(views: cells, animations: [scaleAnimation])