Skip to content

Commit

Permalink
Improve keyboard visible height calculation (#1012)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvasilak committed Sep 19, 2024
1 parent fdb3fe9 commit 645116b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Zotero/Models/KeyboardData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ struct KeyboardData {
let animationOptions: UIView.AnimationOptions

var visibleHeight: CGFloat {
return UIScreen.main.bounds.height - self.endFrame.minY
// endFrame.height might be 0 for a floating keyboard that is hiding, so return 0 for this case.
// Additionally, floating keyboard will not reach the end of the screen, therefore we can ignore it.
guard endFrame.height > 0, endFrame.maxY >= UIScreen.main.bounds.height else { return 0 }
return UIScreen.main.bounds.height - endFrame.minY
}

init?(userInfo: [AnyHashable: Any]) {
Expand Down

0 comments on commit 645116b

Please sign in to comment.