Skip to content

Commit 5172093

Browse files
authored
Merge pull request #31 from EfraimB/bugfix/animation-glitch
Fix for animation glitch when swithcing from a normal textfiled to a password textflied
2 parents 7cf2835 + 62f3ae8 commit 5172093

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

KeyboardLayoutGuide/KeyboardLayoutGuide/Keyboard+LayoutGuide.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,14 @@ open class KeyboardLayoutGuide: UILayoutGuide {
8989

9090
@objc
9191
private func keyboardWillChangeFrame(_ note: Notification) {
92-
if var height = note.keyboardHeight {
92+
if var height = note.keyboardHeight, let duration = note.animationDuration {
9393
if #available(iOS 11.0, *), usesSafeArea, height > 0, let bottom = owningView?.safeAreaInsets.bottom {
9494
height -= bottom
9595
}
9696
heightConstraint?.constant = height
97-
animate(note)
97+
if duration > 0.0 {
98+
animate(note)
99+
}
98100
Keyboard.shared.currentHeight = height
99101
}
100102
}
@@ -133,6 +135,10 @@ extension Notification {
133135
let screenHeight = UIApplication.shared.keyWindow?.bounds.height ?? UIScreen.main.bounds.height
134136
return screenHeight - keyboardFrame.cgRectValue.minY
135137
}
138+
139+
var animationDuration: CGFloat? {
140+
return self.userInfo?[UIResponder.keyboardAnimationDurationUserInfoKey] as? CGFloat
141+
}
136142
}
137143

138144
// Credits to John Gibb for this nice helper :)

0 commit comments

Comments
 (0)