GrowingTextView icon indicating copy to clipboard operation
GrowingTextView copied to clipboard

Scroll to correct position

Open alexsteinerde opened this issue 6 years ago • 1 comments

This function should not scroll to the end or to the top. It should scroll to the cursor position.

I added a workaround for myself:

func textViewDidChangeHeight(_ textView: GrowingTextView, height: CGFloat) {
    UIView.setAnimationsEnabled(false)
    let caret = tableView.convert(textView.caretRect(for: textView.selectedTextRange!.start), from: textView)
    let keyboardTopBorder = textView.bounds.size.height - tableView.frame.width
    if caret.origin.y > keyboardTopBorder && textView.isFirstResponder {
        tableView.scrollRectToVisible(caret, animated: true)
    }
    UIView.setAnimationsEnabled(true)
}

alexsteinerde avatar Nov 04 '17 08:11 alexsteinerde

Thanks for the suggestion. I believe in some case users still expect scroll to the end or the top (at least in my case). Maybe I will add this option in later version.

KennethTsang avatar Dec 17 '17 08:12 KennethTsang