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