Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
MateuszW13 opened this issue Oct 24, 2019 · 4 comments
Open
3 tasks done
Labels

Comments

@MateuszW13
Copy link

MateuszW13 commented Oct 24, 2019

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.

@JoniVR
Copy link
Owner

JoniVR commented Oct 24, 2019

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 JoniVR added bug and removed question labels Oct 24, 2019
@JoniVR JoniVR changed the title [Question] Change speed of scrollToCard method [Bug] scrollToCard animation doesn't look right with custom duration Oct 24, 2019
@MateuszW13
Copy link
Author

MateuszW13 commented Oct 25, 2019

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

@JoniVR
Copy link
Owner

JoniVR commented Oct 25, 2019

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.

@MateuszW13
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants