-
-
Notifications
You must be signed in to change notification settings - Fork 25
👌 IMPROVE: RHS TOC sticky when scrolling option #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
499b061
7923265
2e6acdd
0fe9120
6f9d006
0b98935
17ccb9e
85ed2f2
341ee62
d5e85ab
8fe2483
7f004f0
cb28e45
1bd3d58
43030f4
aa6f864
67bf824
23777b6
db6cdca
ba7f601
f22348c
adde74b
c932aa7
42da195
3ec412e
20c8790
91f2ec9
d00b16f
eb7e422
b50aed5
be53f5c
05cd737
0acf72c
9abf43c
8416d73
6f47f6a
06127b2
a75930f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,3 +27,5 @@ keywords = | |
| twitter = | ||
| twitter_logo_url = | ||
| og_logo_url = | ||
| sticky_contents = False | ||
| persistent_sidebar = False | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,4 +28,5 @@ keywords = | |
| twitter = | ||
| twitter_logo_url = | ||
| og_logo_url = | ||
| sticky_contents = False | ||
| persistent_sidebar = False | ||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,6 @@ | ||||||||||||
| // ScrollSpy Plugin: https://github.com/r3plica/Scrollspy | ||||||||||||
| !function($,window,document,undefined){$.fn.extend({scrollspy:function(options){var defaults={namespace:"scrollspy",activeClass:"active",animate:!1,duration:1e3,offset:0,container:window,replaceState:!1};options=$.extend({},defaults,options);var add=function(ex1,ex2){return parseInt(ex1,10)+parseInt(ex2,10)},findElements=function(links){for(var elements=[],i=0;i<links.length;i++){var link=links[i],hash=$(link).attr("href"),element=$(hash);if(element.length>0){var top=Math.floor(element.offset().top),bottom=top+Math.floor(element.outerHeight());elements.push({element:element,hash:hash,top:top,bottom:bottom})}}return elements},findLink=function(links,hash){for(var i=0;i<links.length;i++){var link=$(links[i]);if(link.attr("href")===hash)return link}},resetClasses=function(links){for(var i=0;i<links.length;i++)$(links[i]).parent().removeClass(options.activeClass)},scrollArea="";return this.each(function(){for(var element=this,container=$(options.container),links=$(element).find("a"),i=0;i<links.length;i++){var link=links[i];$(link).on("click",function(e){var target=$(this).attr("href"),$target=$(target);if($target.length>0){var top=add($target.offset().top,options.offset);options.animate?$("html, body").animate({scrollTop:top},options.duration):window.scrollTo(0,top),e.preventDefault()}})}resetClasses(links);var elements=findElements(links),trackChanged=function(){for(var link,position={top:add($(this).scrollTop(),Math.abs(options.offset)),left:$(this).scrollLeft()},i=0;i<elements.length;i++){var current=elements[i];if(position.top>=current.top&&position.top<current.bottom){var hash=current.hash;if(link=findLink(links,hash)){options.onChange&&scrollArea!==hash&&(options.onChange(current.element,$(element),position),scrollArea=hash),options.replaceState&&history.replaceState({},"","/"+hash),resetClasses(links),link.parent().addClass(options.activeClass);break}}}!link&&"exit"!==scrollArea&&options.onExit&&(options.onExit($(element),position),resetClasses(links),scrollArea="exit",options.replaceState&&history.replaceState({},"","/"))};container.bind("scroll."+options.namespace,function(){trackChanged()}),$(document).ready(function(e){trackChanged()})})}})}(jQuery,window,document); | ||||||||||||
|
||||||||||||
|
|
||||||||||||
| document.addEventListener("DOMContentLoaded", function(){ | ||||||||||||
|
|
||||||||||||
| // Avoid `console` errors in browsers that lack a console. | ||||||||||||
|
|
@@ -315,4 +318,7 @@ document.addEventListener("DOMContentLoaded", function(){ | |||||||||||
| touch: false, | ||||||||||||
| }); | ||||||||||||
|
|
||||||||||||
| }); | ||||||||||||
| // Highlight page TOC links as user scrolls | ||||||||||||
| $(".sticky #bd-toc-nav ul").scrollspy(); | ||||||||||||
|
|
||||||||||||
|
||||||||||||
| var $tocNav = $(".sticky #bd-toc-nav ul"); | |
| if ($tocNav.length > 0) { | |
| $tocNav.scrollspy(); | |
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -467,7 +467,10 @@ tt { | |||||
| width: 200px; | ||||||
|
|
||||||
| .inner { | ||||||
| height: 100%; | ||||||
| &.sticky { | ||||||
| position: sticky; | ||||||
| top: 7rem; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| &-header { | ||||||
|
|
@@ -500,6 +503,13 @@ tt { | |||||
| opacity: 1; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| &.active { | ||||||
| >a { | ||||||
| //color: $color-primary; | ||||||
|
||||||
| //color: $color-primary; |
Copilot
AI
Aug 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the commented out display property. If this rule needs to be disabled, consider removing it entirely or documenting why it's commented out.
| // display: block; |
Copilot
AI
Aug 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value 400rem is a magic number that appears to be used to hide elements off-screen. Consider using a more semantic approach like left: -9999px or display: none with proper accessibility considerations.
| left: 400rem; | |
| left: -9999px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AakashGfude is the option called
theme_sticky_contentsorsticky_contentsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theme_is appended by sphinx itself forhtml_theme_options. Unfortunately, it's neither 😬. The correct one istheme_sticky_toc. I have corrected it.