Skip to content

BugFix - Make input description auto scroll to cursor position when it is out of visible bounds#123

Merged
aritra-tech merged 2 commits intoaritra-tech:developfrom
Devendra34:bugFix/description_auto_scroll
Oct 7, 2023
Merged

BugFix - Make input description auto scroll to cursor position when it is out of visible bounds#123
aritra-tech merged 2 commits intoaritra-tech:developfrom
Devendra34:bugFix/description_auto_scroll

Conversation

@Devendra34
Copy link
Copy Markdown
Contributor

Fixes #91

The approach is to check the current cursor line number: If :-

  1. cursor line number is above first visible line number -> scroll up to cursor position
  2. cursor line number is below last visible line number -> scroll down to cursor position
  3. else cursor is already in visible bounds of first and last visible line -> scroll not required

There is some maths involved to find cursor position, first visible line, last visible line.

  1. Cursor position -> we get this using TextLayoutResult.getLineForOffset() and pass the
  2. firstVisibleLineNumber -> currentScrollValue of parent scrollable layout - scrollOffset. Here scrollOffset is the height of the composable above description textField.
  3. lastVisibleLineNumber -> currentScrollValue of parent scrollable layout + contentSize - scrollOffset. Here content size is the height of scrollable parent composable, scrollOffset is same as before.

Final Result:

auto_scroll (1)

@Devendra34 Devendra34 force-pushed the bugFix/description_auto_scroll branch from a15c3a3 to 41a0add Compare October 7, 2023 09:51
@Devendra34
Copy link
Copy Markdown
Contributor Author

Hi @aritra-tech,
I have fixed the code style formating from last workflow result.

Copy link
Copy Markdown
Owner

@aritra-tech aritra-tech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🙌🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants