Skip to content

Commit 687fb1b

Browse files
committed
Fixed scroll offset adjustment due to inputBarHeight change being done twice sometimes.
When increasing the height constraint of a scrollview and calling layout on it, _adjustContentOffsetIfNecessary is called which adjusts the content offset so that there's no blank space at the bottom. When this happens, the content offset adjustment would happen twice, once by _adjustContentOffsetIfNecessary and once by the code in the block. Have the adjustment be based on the contentOffset before any layout so that it remains accurate.
1 parent 2fbcbe4 commit 687fb1b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Source/SLKTextViewController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ - (void)textDidUpdate:(BOOL)animated
665665
if (inputbarHeight != self.textInputbarHC.constant)
666666
{
667667
CGFloat inputBarHeightDelta = inputbarHeight - self.textInputbarHC.constant;
668+
CGPoint newOffset = CGPointMake(0, self.scrollViewProxy.contentOffset.y + inputBarHeightDelta);
668669
self.textInputbarHC.constant = inputbarHeight;
669670
self.scrollViewHC.constant = [self slk_appropriateScrollViewHeight];
670671

@@ -678,7 +679,7 @@ - (void)textDidUpdate:(BOOL)animated
678679
options:UIViewAnimationOptionCurveEaseInOut|UIViewAnimationOptionLayoutSubviews|UIViewAnimationOptionBeginFromCurrentState
679680
animations:^{
680681
if (!self.isInverted) {
681-
self.scrollViewProxy.contentOffset = CGPointMake(0, self.scrollViewProxy.contentOffset.y + inputBarHeightDelta);
682+
self.scrollViewProxy.contentOffset = newOffset;
682683
}
683684
if (weakSelf.textInputbar.isEditing) {
684685
[weakSelf.textView slk_scrollToCaretPositonAnimated:NO];

0 commit comments

Comments
 (0)