You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
big thx man! but i have collection with sections :( but this is also very useful to me)06.10.2019, 19:54, "Artyom" <[email protected]>:This is my solution, work only with single provider
extension CollectionView {
func scroll(to index: Int, animated: Bool) throws {
guard self.provider as? ComposedProvider == nil else {
throw(CollectionKitError.unableToScroll)
}
guard let provider = self.provider else {
throw(CollectionKitError.unableToScroll)
}
let itemFrame = provider.frame(at: index)
var targetPoint = itemFrame.origin
let itemXDiff = self.contentSize.width - itemFrame.origin.x
let itemYDiff = self.contentSize.height - itemFrame.origin.y
if itemXDiff < self.visibleFrame.width || itemYDiff < self.visibleFrame.height {
targetPoint = CGPoint(x: self.contentSize.width - self.visibleFrame.width, y:self.contentSize.height - self.visibleFrame.height)
}
if animated {
UIView.animate(withDuration: 0.3) {
self.contentOffset = targetPoint
}
} else {
self.contentOffset = targetPoint
}
}
}
enum CollectionKitError: Error {
case unableToScroll
}
—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread.
thx!
The text was updated successfully, but these errors were encountered: