Skip to content

Commit 52d37c8

Browse files
authored
Merge pull request #14 from RxSwiftCommunity/pan-gesture-changed
Take only `.changed` state from pan gesture recognizer
2 parents 3e7074d + f73a4e8 commit 52d37c8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Sources/RxKeyboard.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class RxKeyboard: NSObject {
4343
height: 0
4444
)
4545
let frameVariable = Variable<CGRect>(defaultFrame)
46-
self.frame = frameVariable.asDriver()
46+
self.frame = frameVariable.asDriver().distinctUntilChanged()
4747
self.visibleHeight = self.frame.map { UIScreen.main.bounds.height - $0.origin.y }
4848

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

0 commit comments

Comments
 (0)