Skip to content
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

Added an offset parameter to the scrollspy for more accurate detection #1387

Merged
merged 1 commit into from
Jan 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 1 addition & 26 deletions mkdocs/themes/mkdocs/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,39 +39,14 @@ ul.nav .main {
/*
* The code below adds some padding to the top of the current anchor target so
* that, when navigating to it, the header isn't hidden by the navbar at the
* top. This is especially complicated because we want to *remove* the padding
* after navigation so that hovering over the header shows the permalink icon
* correctly. Thus, we create a CSS animation to remove the extra padding after
* a second. We have two animations so that navigating to an anchor within the
* page always restarts the animation.
*
* See <https://github.com/mkdocs/mkdocs/issues/843> for more details.
* top.
*/
:target::before {
content: "";
display: block;
margin-top: -75px;
height: 75px;
pointer-events: none;
animation: 0s 1s forwards collapse-anchor-padding-1;
}

.clicky :target::before {
animation-name: collapse-anchor-padding-2;
}

@keyframes collapse-anchor-padding-1 {
to {
margin-top: 0;
height: 0;
}
}

@keyframes collapse-anchor-padding-2 {
to {
margin-top: 0;
height: 0;
}
}

h1 {
Expand Down
7 changes: 1 addition & 6 deletions mkdocs/themes/mkdocs/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,7 @@ $(document).ready(function() {

$('body').scrollspy({
target: '.bs-sidebar',
});

/* Toggle the `clicky` class on the body when clicking links to let us
retrigger CSS animations. See ../css/base.css for more details. */
$('a').click(function(e) {
$('body').toggleClass('clicky');
offset: 100
});

/* Prevent disabled links from causing a page reload */
Expand Down