diff --git a/Classes/Source.swift b/Classes/Source.swift index 1480246..a3679a8 100644 --- a/Classes/Source.swift +++ b/Classes/Source.swift @@ -11,6 +11,8 @@ import UIKit open class Source: NSObject { open fileprivate(set) var sections = [SectionType]() + public var scrollViewDelegate: UIScrollViewDelegate? + public override init() { super.init() } @@ -227,6 +229,63 @@ extension Source: UITableViewDelegate { } } +// MARK: - Scroll View Delegate +extension Source: UIScrollViewDelegate { + + public func scrollViewDidScroll(_ scrollView: UIScrollView) { + scrollViewDelegate?.scrollViewDidScroll?(scrollView) + } + + public func scrollViewDidZoom(_ scrollView: UIScrollView) { + scrollViewDelegate?.scrollViewDidZoom?(scrollView) + } + + public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { + scrollViewDelegate?.scrollViewWillBeginDragging?(scrollView) + } + + public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer) { + scrollViewDelegate?.scrollViewWillEndDragging?(scrollView, withVelocity: velocity, targetContentOffset: targetContentOffset) + } + + public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { + scrollViewDelegate?.scrollViewDidEndDragging?(scrollView, willDecelerate: decelerate) + } + + public func scrollViewWillBeginDecelerating(_ scrollView: UIScrollView) { + scrollViewDelegate?.scrollViewWillBeginDecelerating?(scrollView) + } + + public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { + scrollViewDelegate?.scrollViewDidEndDecelerating?(scrollView) + } + + public func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { + scrollViewDelegate?.scrollViewDidEndScrollingAnimation?(scrollView) + } + + public func viewForZooming(in scrollView: UIScrollView) -> UIView? { + return scrollViewDelegate?.viewForZooming?(in: scrollView) + } + + public func scrollViewWillBeginZooming(_ scrollView: UIScrollView, with view: UIView?) { + scrollViewDelegate?.scrollViewWillBeginZooming!(scrollView, with: view) + } + + public func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) { + scrollViewDelegate?.scrollViewDidEndZooming!(scrollView, with: view, atScale: scale) + } + + public func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool { + return scrollViewDelegate?.scrollViewShouldScrollToTop?(scrollView) ?? true + } + + public func scrollViewDidScrollToTop(_ scrollView: UIScrollView) { + scrollViewDelegate?.scrollViewDidScrollToTop?(scrollView) + } + +} + // MARK: Private method extension Source {