Skip to content

Instantly share code, notes, and snippets.

@maoyama
Last active August 18, 2017 14:53
Show Gist options
  • Select an option

  • Save maoyama/7c6d17d003d3db77d2b2e5dbdd3c7c84 to your computer and use it in GitHub Desktop.

Select an option

Save maoyama/7c6d17d003d3db77d2b2e5dbdd3c7c84 to your computer and use it in GitHub Desktop.
//
// UIScrollView+rearchedBottom.swift
// architecture
//
// Created by MakotoAoyama on 8/18/17.
//
import Foundation
import ReactiveSwift
import Result
extension Reactive where Base: UIScrollView {
var reachedBottom: Signal<CGPoint?, NoError> {
get {
let any: Signal<Any?, NoError> = self.signal(forKeyPath: #keyPath(UIScrollView.contentOffset))
return any.map { (any) -> CGPoint? in
guard let point = any as? CGPoint else {
return nil
}
return point
}.filter { (point) -> Bool in
guard let y = point?.y else {
return false
}
if y + self.base.bounds.height > self.base.contentSize.height {
return true
}
return false
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment