[Bug] `scrollToCard` animation doesn't look right with custom duration
MateuszW13 opened this issue · comments
New Issue Checklist
- I read the documentation.
- I searched for existing GitHub issues.
- I searched Google for a solution to my issue if applicable.
Question
Is it possible to slow down the animation of scrollToCard(at:animated) method ?
I was trying to slow it done with:
UIView.animate(withDuration: 2.0, animations: {
self.view.setContentOffset(point, animated: false)
})
and
UIView.animate(withDuration: 2.0, animations: {
self.view.scrollToCard(at: cards.count, animated: false)
})
and both of the methods don't seem to work for me.
The reason why it probably doesn't do anything is because cards.count
probably is out of bounds (zero based index in array so you have to do cards.count - 1
, the underlying function actually checks for this and will not scroll if you're out of bounds.
That said, if you use it with UIView.animate
it currently seems to be very buggy... like this:
Yup, I came to this point as well. Is there any other way to reduce this animation speed or fix the buggy part ?
Apparently, using UIView.animate()
doesn't work properly on a normal collectionview either. It has something to do with cell creation. Also, setting the animated parameter to false also doesn't execute the actual animation code, which is probably what's happening here.
Have you tried wrapping it inside a CATransaction
?
See this comment here:
https://stackoverflow.com/a/16693712/6863743
It's in objective-c but shouldn't be hard to translate to swift.
edit: nvm probably won't work but worth a shot.
I have tried this solution as well and still it is not working :(