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 committed Jan 17, 2024
1 parent 38345cb commit 6af641e
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 6af641e

Please sign in to comment.