Skip to content

Conversation

scdekov
Copy link

@scdekov scdekov commented Sep 24, 2025

This PR adds opt-in support for variable-height rows when virtual is enabled. It measures rendered rows, maintains cumulative offsets, and uses binary search to map scrollTop to item indices, ensuring smooth, accurate scrolling even when content wraps or custom renders change row height.

The main motivation is to allow showing longer json string values wrapped so that they're more readable compared to having a long horizontal scroll when using virtual scrolling.

closes: #286

@leezng leezng self-requested a review September 26, 2025 02:10
@leezng
Copy link
Owner

leezng commented Sep 30, 2025

@scdekov Thank you so much! This is a great feature.

However, I've noticed a problem with this commit: component rendering becomes sluggish when the browser viewport width changes, such as by dragging and resizing the browser. Could you help fix this?

The latest version doesn't have this lag; see https://leezng.github.io/vue-json-pretty/

@scdekov
Copy link
Author

scdekov commented Oct 3, 2025

Hi @leezng thanks for checking the PR! From what I see the sluggishness is coming from the native text area as I'm putting some big chunk of text there. Commenting out the textarea from the example component seems to be resolving the issue.

I guess if we add wrap="off" to the textarea it get's better. If we also reduce the text there it works normally. Any preference on how to go about it?

Untitled.mov

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

Successfully merging this pull request may close these issues.

Virtual scrolling jumps around for large text items
2 participants