🎯 Improve virtual scroller to center items during scroll for better visibility

This commit is contained in:
2026-01-28 21:17:57 +00:00
parent 32698e5261
commit 1a398b2528

View File

@@ -761,7 +761,16 @@ function scrollToResult() {
// Use virtual scroller API if available (for large files) // Use virtual scroller API if available (for large files)
if (virtualScroller.value && displayLines.value.length > 1000) { if (virtualScroller.value && displayLines.value.length > 1000) {
nextTick(() => { nextTick(() => {
virtualScroller.value.scrollToItem(lineIndex); // Calculate the scroll position to center the item
const scroller = virtualScroller.value;
const itemHeight = lineHeight.value;
const containerHeight = scroller.$el.clientHeight;
// Calculate scroll position to center the item
const targetScrollTop = (lineIndex * itemHeight) - (containerHeight / 2) + (itemHeight / 2);
// Use the scroller's internal scrollTop
scroller.$el.scrollTop = Math.max(0, targetScrollTop);
}); });
} else { } else {
// Fallback for non-virtual scrolled content // Fallback for non-virtual scrolled content