Skip to content

Commit

Permalink
Merge pull request #365 from melexis/scroll-into-view
Browse files Browse the repository at this point in the history
Display selected items at the top of the browser viewport
  • Loading branch information
JasperCraeghs authored Jan 3, 2024
2 parents c75e8c0 + 45cfc11 commit 92dc9aa
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mlx/traceability/assets/traceability.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ $(document).ready(function () {
$('p.admonition-title').each(function (i) {
$(this).children('a').first().denyPermalinkStyling($(this));
});

// if an item was selected, ensure it's displayed at the top of the viewport
if (location.hash) {
const anchorId = location.hash.slice(1);
const element = document.getElementById(anchorId);
if (element) {
element.scrollIntoView(true, { block: "start", inline: "nearest" });
}
}
});

// item
Expand Down

0 comments on commit 92dc9aa

Please sign in to comment.