From d05b1b00c9b50637ec4814cb7eac28bf13bdd354 Mon Sep 17 00:00:00 2001 From: Artur Date: Mon, 20 May 2019 15:27:37 +0300 Subject: [PATCH] TableView Content offset binding was fixed --- .../Classes/Controllers/BaseScrollContentController.swift | 5 ++--- .../UIKit/UIScrollView/UIScrollView+RxBindings.swift | 8 ++------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Sources/Classes/Controllers/BaseScrollContentController.swift b/Sources/Classes/Controllers/BaseScrollContentController.swift index 71a24404..6c1ea683 100644 --- a/Sources/Classes/Controllers/BaseScrollContentController.swift +++ b/Sources/Classes/Controllers/BaseScrollContentController.swift @@ -34,10 +34,9 @@ open class BaseScrollContentController: B /// /// - Parameter bottomInsetDriver: Driver that emits CGFloat bottom inset changes. public func bindBottomInsetBinding(from bottomInsetDriver: Driver) { - let contentInsetObservable = customView.scrollView.rx - .observe(UIEdgeInsets.self, #keyPath(UIScrollView.contentInset)) + let contentInsetObservable = customView.scrollView.rx.contentOffset - let bottomInset = contentInsetObservable.map { $0?.bottom ?? 0 } + let bottomInset = contentInsetObservable.map { $0.y } bottomInsetDisposable = bottomInsetDriver.asObservable() .withLatestFrom(bottomInset) { $0 + $1 } diff --git a/Sources/Extensions/UIKit/UIScrollView/UIScrollView+RxBindings.swift b/Sources/Extensions/UIKit/UIScrollView/UIScrollView+RxBindings.swift index 5b5be346..c748aaf1 100644 --- a/Sources/Extensions/UIKit/UIScrollView/UIScrollView+RxBindings.swift +++ b/Sources/Extensions/UIKit/UIScrollView/UIScrollView+RxBindings.swift @@ -28,12 +28,8 @@ public extension Reactive where Base: UIScrollView { /// Binder instance that updates contentInset bottom value. var bottomInsetBinder: Binder { return Binder(base) { base, value in - // Quick workaround. - // For some reason code in closure won't work without async call. - DispatchQueue.main.async { - base.contentInset.bottom = value - base.scrollIndicatorInsets.bottom = value - } + base.contentInset.bottom = value + base.scrollIndicatorInsets.bottom = value } } }