Skip to content

Commit 4b9cbe9

Browse files
committed
fixed willShowVisibleHeight called when hiding
The willShowVisibleHeight Driver was being called not only when the keyboard would show but also when the keyboard is hidden. The added condition ensures this isn't called when hiding. This way the skip(1) isn't needed either.
1 parent be305c2 commit 4b9cbe9

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Sources/RxKeyboard/RxKeyboard.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ public class RxKeyboard: NSObject, RxKeyboardType {
6262
self.visibleHeight = self.frame.map { UIScreen.main.bounds.height - $0.origin.y }
6363
self.willShowVisibleHeight = self.visibleHeight
6464
.scan((visibleHeight: 0, isShowing: false)) { lastState, newVisibleHeight in
65-
return (visibleHeight: newVisibleHeight, isShowing: lastState.visibleHeight == 0)
65+
return (visibleHeight: newVisibleHeight, isShowing: lastState.visibleHeight == 0 && newVisibleHeight > 0)
6666
}
6767
.filter { state in state.isShowing }
6868
.map { state in state.visibleHeight }
69-
.skip(1)
7069
self.isHidden = self.visibleHeight.map({ $0 == 0.0 }).distinctUntilChanged()
7170
super.init()
7271

0 commit comments

Comments
 (0)