Skip to content

Commit

Permalink
Merge pull request #52 from cpwhidden/will-show
Browse files Browse the repository at this point in the history
fixed willShowVisibleHeight called when hiding
  • Loading branch information
devxoul authored Dec 28, 2017
2 parents be305c2 + 4b9cbe9 commit a5b53e1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions Sources/RxKeyboard/RxKeyboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ public class RxKeyboard: NSObject, RxKeyboardType {
self.visibleHeight = self.frame.map { UIScreen.main.bounds.height - $0.origin.y }
self.willShowVisibleHeight = self.visibleHeight
.scan((visibleHeight: 0, isShowing: false)) { lastState, newVisibleHeight in
return (visibleHeight: newVisibleHeight, isShowing: lastState.visibleHeight == 0)
return (visibleHeight: newVisibleHeight, isShowing: lastState.visibleHeight == 0 && newVisibleHeight > 0)
}
.filter { state in state.isShowing }
.map { state in state.visibleHeight }
.skip(1)
self.isHidden = self.visibleHeight.map({ $0 == 0.0 }).distinctUntilChanged()
super.init()

Expand Down

0 comments on commit a5b53e1

Please sign in to comment.