Skip to content

Commit

Permalink
fix: improve autoscroll to highlighted block
Browse files Browse the repository at this point in the history
  • Loading branch information
javier-godoy authored and paodb committed Jan 17, 2024
1 parent b9c1b6f commit 7022293
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/resources/META-INF/resources/frontend/code-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,16 @@ pre[class*="language-"] {
div.style.top= `calc( ${top}px + 0.75em)`;
div.style.height= `${height}px`;

//scroll to the begin of the marked block
if ((begin as any).scrollIntoViewIfNeeded) {
(begin as any).scrollIntoViewIfNeeded();
} else {
(begin as any).scrollIntoView()
const scrollIntoView = elem => {
if ((elem as any).scrollIntoViewIfNeeded) {
(elem as any).scrollIntoViewIfNeeded();
} else {
(elem as any).scrollIntoView()
}
}

scrollIntoView(end);
scrollIntoView(begin);
}
}
}
Expand Down

0 comments on commit 7022293

Please sign in to comment.