Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll to correct position #20

Open
alexsteinerde opened this issue Nov 4, 2017 · 1 comment
Open

Scroll to correct position #20

alexsteinerde opened this issue Nov 4, 2017 · 1 comment

Comments

@alexsteinerde
Copy link
Contributor

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)
}
@KennethTsang
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants