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

Autoplay feature #21

Open
pballada opened this issue May 22, 2017 · 5 comments
Open

Autoplay feature #21

pballada opened this issue May 22, 2017 · 5 comments

Comments

@pballada
Copy link

Hi,
I'm working with an autoplay feature and have two questions.

First one is that to go to next indexPath, I'm using the scrollToItem function, but is not always working as expected, sometimes it scrolls and sometimes not.

collectionView.scrollToItem(at: nextIndexPath, at: UICollectionViewScrollPosition.left, animated: true)

Maybe I'm missing something here..

And second, there's a way to change the speed of the animation of scrollToItem? Looks it's fixed by the system..

Thanks!

@pballada
Copy link
Author

Actually, autoplay works with all animations with a Timer and scrollToItem, except the crossfade animation, not sure why. Any light will be welcome.

No luck neither related to the speed of the animation when using scrollToItem.

thanks for the library!

@kelsheikh
Copy link

Hi, I have also had trouble using scrollToItem with this UICollectionViewLayout subclass in an autoplay feature. The cell does not seem to get centered when I use LinearCardAttributesAnimator and then causes issues going forward. I have tried adding dispatch delays and wrapping in a UIView.animate but have had no luck. I love this library and just needed to be able to use scrollToItem.

collectionView.scrollToItem(at: IndexPath, at: centeredHorizontally, animated: true)

Was there any kinda of fix or workaround for this to scroll to a specific cell and have it centered on cell?

@romansorochak
Copy link

@mixmastertube @kelsheikh try to use scrollToVisibleRect which is inherited from UIScrollView

@mstroshin
Copy link

Hi, I use page layout and I can scroll the pages forward, but I can't do it backwards.

collectionView.scrollToItem(at: IndexPath, at: centeredHorizontally, animated: true)

let rect = self.collectionView.layoutAttributesForItem(at: indexPath)!.frame self.collectionView.scrollRectToVisible(rect, animated: animated)

Both do not work.
Сan you help with this problem?

@pballada
Copy link
Author

Manage to make it work for the crossfade using:

collectionView.setContentOffset(CGPoint(x: CGFloat(indexPath.row) * collectionView.frame.size.width, y: 0), animated: animated)

instead of:
collectionView.scrollToItem(at: indexPath, at: UICollectionView.ScrollPosition.left, animated: animated)

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

No branches or pull requests

4 participants