VerticalCardSwiper icon indicating copy to clipboard operation
VerticalCardSwiper copied to clipboard

[Bug] `scrollToCard` animation doesn't look right with custom duration

Open MateuszW13 opened this issue 6 years ago • 4 comments

New Issue Checklist

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.

MateuszW13 avatar Oct 24 '19 13:10 MateuszW13

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:

ezgif com-video-to-gif so that's something that definitely needs fixing.

JoniVR avatar Oct 24 '19 20:10 JoniVR

Yup, I came to this point as well. Is there any other way to reduce this animation speed or fix the buggy part ?

MateuszW13 avatar Oct 25 '19 06:10 MateuszW13

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.

JoniVR avatar Oct 25 '19 10:10 JoniVR

I have tried this solution as well and still it is not working :(

MateuszW13 avatar Nov 07 '19 06:11 MateuszW13