Closed JoniVR closed 6 years ago
Can't seem to find out the exact issue, I discovered that there's also an animation glitch happening on the last 2 cells, so it could have something to do with the fact that animations need to be handled differently for the first and last cells.
Here's a video showing the visual glitches
edit: Seems like the top animation glitch only happens after pressing the status bar to "scroll-to-top".
I asked a question on stackoverflow about this, and someone suggested that it is probably related to the implicit animations inside of performBatchUpdates
to remove the cell after swiping it away.
collectionView.performBatchUpdates({
collectionView.deleteItems(at: [indexPathToRemove])
}) { [weak self] (finished) in
if finished {
self?.collectionView.collectionViewLayout.invalidateLayout()
}
}
I tested this out and it does look like this might be the case, I'll look into (hopefully) fixing it whenever I have some more spare time.
General
I'm just going to use this issue to document this bug, so people know I'm aware of it and looking for fixes. The bug is a visual animation glitch that sometimes happens when the user swipes away a card.
I personally think it's related to resetting the anchorPoint of the CardCell, but I'm not sure about it yet.Steps to reproduce
Description
~~After some testing I think this bug is caused by calling
self.layer.anchorPoint = CGPoint(x: 0.5, y: 0.5)
inside oflayoutSubviews()
in theCardCell
. We have to do this to reset the anchorPoint (x: 0.5, y: 0.5 is the default anchorPoint).~~The problem is that we're manipulating the anchorPoint to animate the card, but need to reset the anchorPoint after callingresetToCenterPosition()
. We can't reset the anchorPoint inside ofresetToCenterPosition()
(as far as I'm aware) because that screws up the animation. So I tried putting it inlayoutSubviews()
, this worked for the most part, except that it is causing this behaviour (you can test when it's getting called by putting a print statement inside of layoutSubviews).So I need to find a way to reset the anchorPoint after callingresetToCenterPosition()
and before the user starts scrolling. I'm just not sure where to put it as of now.edit: After some further testing it looks like the issue is not related to the anchorPoint being reset, looking into it further to find the cause.
More
As always, any help is always appreciated, if you found a fix or have a solution before I do, feel free to create a Pull Request or respond to this issue.