✨ Improve scroll-to-result functionality with smoother scrolling and better fallback handling
This commit is contained in:
@@ -619,15 +619,17 @@ function scrollToResult() {
|
||||
|
||||
const lineNumber = lineIndex + 1; // Convert to 1-based line number
|
||||
const lineElement = document.querySelector(`[data-line="${lineNumber}"]`);
|
||||
|
||||
|
||||
if (lineElement) {
|
||||
// Scroll to element
|
||||
lineElement.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
|
||||
|
||||
// For virtual scroller, ensure it's rendered by waiting a tick
|
||||
if (!lineElement.textContent) {
|
||||
setTimeout(() => {
|
||||
const retryElement = document.querySelector(`[data-line="${lineNumber}"]`);
|
||||
const retryElement = document.querySelector(
|
||||
`[data-line="${lineNumber}"]`
|
||||
);
|
||||
retryElement?.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}, 100);
|
||||
}
|
||||
@@ -635,7 +637,9 @@ function scrollToResult() {
|
||||
// Fallback: scroll container to approximate position
|
||||
const container = document.querySelector('.scroller, .lines-container');
|
||||
if (container) {
|
||||
const estimatedScroll = (lineIndex / displayLines.value.length) * (container.scrollHeight - container.clientHeight);
|
||||
const estimatedScroll =
|
||||
(lineIndex / displayLines.value.length) *
|
||||
(container.scrollHeight - container.clientHeight);
|
||||
container.scrollTop = estimatedScroll;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user