Skip to content

Commit

Permalink
Use intersection instead of origin for calculating visible height.
Browse files Browse the repository at this point in the history
  • Loading branch information
yongseongkim committed May 24, 2021
1 parent 085fd99 commit 9c72dc3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/RxKeyboard/RxKeyboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class RxKeyboard: NSObject, RxKeyboardType {
)
let frameVariable = BehaviorRelay<CGRect>(value: defaultFrame)
self.frame = frameVariable.asDriver().distinctUntilChanged()
self.visibleHeight = self.frame.map { UIScreen.main.bounds.height - $0.origin.y }
self.visibleHeight = self.frame.map { UIScreen.main.bounds.intersection($0).height }
self.willShowVisibleHeight = self.visibleHeight
.scan((visibleHeight: 0, isShowing: false)) { lastState, newVisibleHeight in
return (visibleHeight: newVisibleHeight, isShowing: lastState.visibleHeight == 0 && newVisibleHeight > 0)
Expand Down

0 comments on commit 9c72dc3

Please sign in to comment.