Merge pull request #1555 from politan8/bugfix/scroll

#1529 fix for collection view content inset
This commit is contained in:
Jakub Kašpar
2021-03-13 21:44:33 +01:00
committed by GitHub
2 changed files with 6 additions and 4 deletions
+2
View File
@@ -6,6 +6,8 @@ The changelog for `MessageKit`. Also see the [releases](https://github.com/Messa
### Fixed
- Fixes an issue with Scroll problem on new messages with keyboard open [#1529](https://github.com/MessageKit/MessageKit/pull/1529) by [@politan8](https://github.com/politan8)
### Added
### Changed
@@ -98,6 +98,10 @@ internal extension MessagesViewController {
let newBottomInset = requiredScrollViewBottomInset(forKeyboardFrame: keyboardEndFrame)
let differenceOfBottomInset = newBottomInset - messageCollectionViewBottomInset
UIView.performWithoutAnimation {
messageCollectionViewBottomInset = newBottomInset
}
if maintainPositionOnKeyboardFrameChanged && differenceOfBottomInset != 0 {
let contentOffset = CGPoint(x: messagesCollectionView.contentOffset.x, y: messagesCollectionView.contentOffset.y + differenceOfBottomInset)
// Changing contentOffset to bigger number than the contentSize will result in a jump of content
@@ -107,10 +111,6 @@ internal extension MessagesViewController {
}
messagesCollectionView.setContentOffset(contentOffset, animated: false)
}
UIView.performWithoutAnimation {
messageCollectionViewBottomInset = newBottomInset
}
}
// MARK: - Inset Computation