From d833b4371534886ca96247ec1b86401bf870e70d Mon Sep 17 00:00:00 2001 From: Adam Leitgeb Date: Thu, 23 Apr 2020 21:48:44 +0800 Subject: [PATCH] Add open method that is being called every time sections are updated --- Sources/DataSource/DataSource.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Sources/DataSource/DataSource.swift b/Sources/DataSource/DataSource.swift index 9dbb347..ac3d0e4 100644 --- a/Sources/DataSource/DataSource.swift +++ b/Sources/DataSource/DataSource.swift @@ -6,7 +6,7 @@ open class DataSource: NSObject { public var sections: [Section] = [] { didSet { - canCallScrollToBottom = true + sectionsDidUpdate(sections) } } @@ -25,8 +25,16 @@ open class DataSource: NSObject { self.sections = sections } - // MARK: - Scroll view delegate + // MARK: - Utilities + open func sectionsDidUpdate(_ sections: [Section]) { + canCallScrollToBottom = true + } +} + +// MARK: - UIScrollViewDelegate + +extension DataSource { open func scrollViewDidScroll(_ scrollView: UIScrollView) { let offsetY = scrollView.contentOffset.y let contentHeight = scrollView.contentSize.height