Last active
August 18, 2017 14:53
-
-
Save maoyama/7c6d17d003d3db77d2b2e5dbdd3c7c84 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // 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