Skip to content

Commit 7022293

Browse files
javier-godoypaodb
authored andcommitted
fix: improve autoscroll to highlighted block
1 parent b9c1b6f commit 7022293

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/main/resources/META-INF/resources/frontend/code-viewer.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,16 @@ pre[class*="language-"] {
449449
div.style.top= `calc( ${top}px + 0.75em)`;
450450
div.style.height= `${height}px`;
451451

452-
//scroll to the begin of the marked block
453-
if ((begin as any).scrollIntoViewIfNeeded) {
454-
(begin as any).scrollIntoViewIfNeeded();
455-
} else {
456-
(begin as any).scrollIntoView()
452+
const scrollIntoView = elem => {
453+
if ((elem as any).scrollIntoViewIfNeeded) {
454+
(elem as any).scrollIntoViewIfNeeded();
455+
} else {
456+
(elem as any).scrollIntoView()
457+
}
457458
}
459+
460+
scrollIntoView(end);
461+
scrollIntoView(begin);
458462
}
459463
}
460464
}

0 commit comments

Comments
 (0)