Tweak compose text view scrolling behavior

This commit is contained in:
Shadowfacts 2020-11-11 12:14:36 -05:00
parent fc888b168c
commit 80cca7673a
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 3 additions and 2 deletions

View File

@ -211,9 +211,10 @@ struct MainComposeWrappedTextView: UIViewRepresentable {
let cursorRect = textView.caretRect(for: range.start)
var rectToMakeVisible = textView.convert(cursorRect, to: scrollView)
// move Y position of the rect that will be made visible down by the cursor's height so that there's
// expand the rect to be three times the cursor height centered on the cursor so that there's
// some space between the bottom of the line of text being edited and the top of the keyboard
rectToMakeVisible.origin.y += cursorRect.height
rectToMakeVisible.origin.y -= cursorRect.height
rectToMakeVisible.size.height *= 3
let animator = UIViewPropertyAnimator(duration: 0.1, curve: .linear) {
scrollView.scrollRectToVisible(rectToMakeVisible, animated: false)