From 80cca7673aca33c5b06fe804843c573a571b08c2 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 11 Nov 2020 12:14:36 -0500 Subject: [PATCH] Tweak compose text view scrolling behavior --- Tusker/Screens/Compose/MainComposeTextView.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Tusker/Screens/Compose/MainComposeTextView.swift b/Tusker/Screens/Compose/MainComposeTextView.swift index 3092b7c8..6d0ba707 100644 --- a/Tusker/Screens/Compose/MainComposeTextView.swift +++ b/Tusker/Screens/Compose/MainComposeTextView.swift @@ -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)