-
Notifications
You must be signed in to change notification settings - Fork 39
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
Scrolling through code #3
Comments
I will try to find out a way to create effect that you are looking for. Meanwhile, have you tried using iCarousel ? It has a property |
Same Issue, I took a day long to try to add such a thing ! 😢 |
Hi guys, //speed of 10 would mean 10pts/second
@objc public func autoScroll(withSpeed speed: CGFloat) {
self.speed = speed
startScrolling()
}
@objc private func startScrolling() {
if (speed > 0) {
collectionView.layer.removeAllAnimations()
UIView.animate(withDuration: TimeInterval(1/speed), delay: 0, options: [.beginFromCurrentState, .allowUserInteraction, .curveLinear]
, animations: {
// Check for scrolling direction.
if (scrollingDirection == .horizontal) {
self.collectionView.setContentOffset(CGPoint(x: self.collectionView.contentOffset.x + 1, y: self.collectionView.contentOffset.y), animated: false)
} else if (scrollingDirection == .vertical) {
self.collectionView.setContentOffset(CGPoint(x: self.collectionView.contentOffset.x, y: self.collectionView.contentOffset.y + 1), animated: false)
}
})
// Calling this method again at 70% completion of the animation so the next animation
// appear in continuation.
perform(#selector(ViewController.startScrolling), with: nil, afterDelay: TimeInterval((1/speed) * 0.7))
}
} It may not work very well for all values of speed. You might see some fluctuations with higher value of speed. In the sample included, I started seeing fluctuations at speed above 800. Try it out and let me know if it works. |
Is it possible to scroll the collection view using code, for a long time just like casino slots?
The text was updated successfully, but these errors were encountered: