TableView Content offset binding was fixed

This commit is contained in:
Artur 2019-05-20 15:27:37 +03:00
parent 971e495b6d
commit d05b1b00c9
2 changed files with 4 additions and 9 deletions

View File

@ -34,10 +34,9 @@ open class BaseScrollContentController<ViewModel, View: ScrollViewHolderView>: B
///
/// - Parameter bottomInsetDriver: Driver that emits CGFloat bottom inset changes.
public func bindBottomInsetBinding(from bottomInsetDriver: Driver<CGFloat>) {
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 }

View File

@ -28,12 +28,8 @@ public extension Reactive where Base: UIScrollView {
/// Binder instance that updates contentInset bottom value.
var bottomInsetBinder: Binder<CGFloat> {
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
}
}
}