Skip to content

Commit

Permalink
Merge pull request #14 from RxSwiftCommunity/pan-gesture-changed
Browse files Browse the repository at this point in the history
Take only `.changed` state from pan gesture recognizer
  • Loading branch information
devxoul authored Jan 18, 2017
2 parents 3e7074d + f73a4e8 commit 52d37c8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Sources/RxKeyboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class RxKeyboard: NSObject {
height: 0
)
let frameVariable = Variable<CGRect>(defaultFrame)
self.frame = frameVariable.asDriver()
self.frame = frameVariable.asDriver().distinctUntilChanged()
self.visibleHeight = self.frame.map { UIScreen.main.bounds.height - $0.origin.y }

super.init()
Expand Down Expand Up @@ -82,7 +82,8 @@ public class RxKeyboard: NSObject {
let didPan = self.panRecognizer.rx.event
.withLatestFrom(frameVariable.asObservable()) { ($0, $1) }
.flatMap { (gestureRecognizer, frame) -> Observable<CGRect> in
guard let window = UIApplication.shared.windows.first,
guard case .changed = gestureRecognizer.state,
let window = UIApplication.shared.windows.first,
frame.origin.y < UIScreen.main.bounds.height
else { return .empty() }
let origin = gestureRecognizer.location(in: window)
Expand Down

0 comments on commit 52d37c8

Please sign in to comment.