Skip to content

Commit

Permalink
Scroll to active left sidebar item
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisbernard committed Sep 12, 2024
1 parent 2b2ae20 commit 15110c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
traverse = proc do |klasses|
has_active_descendant = false
-%>
<ul class="link-list">
<ul class="link-list" id="class-and-module-index">
<%- klasses.each do |index_klass| -%>
<%- if children = all_classes[index_klass.full_name] -%>
<li class="<%= "active" if defined?(current) && (index_klass == current) %>">
Expand Down
6 changes: 6 additions & 0 deletions lib/rdoc/generator/template/rorvswild/js/darkfish.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,16 @@ function hookScrollSpy() {
anchors.forEach(anchor => observer.observe(anchor));
}

function scrollToActiveLeftSidebarItem() {
const item = document.querySelector("#class-and-module-index .active")
item && item.scrollIntoView({block: "center"})
}

document.addEventListener('DOMContentLoaded', function() {
hookSourceViews();
hookSearch();
hookFocus();
hookSidebar();
hookScrollSpy();
scrollToActiveLeftSidebarItem();
});

0 comments on commit 15110c5

Please sign in to comment.