Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Store keyboard height earlier #512

Merged
merged 2 commits into from
Sep 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions Source/SLKTextViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1352,29 +1352,28 @@ - (void)slk_willShowOrHideKeyboard:(NSNotification *)notification
return;
}

// Updates and notifies about the keyboard status update
if ([self slk_updateKeyboardStatus:status]) {
// Posts custom keyboard notification, if logical conditions apply
[self slk_postKeyboarStatusNotification:notification];
}

// Programatically stops scrolling before updating the view constraints (to avoid scrolling glitch).
if (status == SLKKeyboardStatusWillShow) {
[self.scrollViewProxy slk_stopScrolling];
}

// Hides the auto-completion view if the keyboard is being dismissed.
if (![self.textView isFirstResponder] || status == SLKKeyboardStatusWillHide) {
[self slk_hideAutoCompletionViewIfNeeded];
}

// Stores the previous keyboard height
CGFloat previousKeyboardHeight = self.keyboardHC.constant;

// Updates the height constraints' constants
self.keyboardHC.constant = [self slk_appropriateKeyboardHeightFromNotification:notification];
self.scrollViewHC.constant = [self slk_appropriateScrollViewHeight];

// Updates and notifies about the keyboard status update
if ([self slk_updateKeyboardStatus:status]) {
// Posts custom keyboard notification, if logical conditions apply
[self slk_postKeyboarStatusNotification:notification];
}

// Hides the auto-completion view if the keyboard is being dismissed.
if (![self.textView isFirstResponder] || status == SLKKeyboardStatusWillHide) {
[self slk_hideAutoCompletionViewIfNeeded];
}

NSInteger curve = [notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue];
NSTimeInterval duration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
Expand Down