Skip to content
Snippets Groups Projects
Commit e79a5ffe authored by Michael McAndrew's avatar Michael McAndrew Committed by GitHub
Browse files

Merge pull request #39 from seanmadsen/nav-auto-scroll-to-active

Scroll to active navigation menu item on page load, when necessary
parents a3491cd2 1e60b4e7
No related branches found
No related tags found
No related merge requests found
// Automatically scroll the navigation menu to the active element
// https://github.com/civicrm/civicrm-dev-docs/issues/21
$.fn.isFullyWithinViewport = function(){
var viewport = {};
viewport.top = $(window).scrollTop();
viewport.bottom = viewport.top + $(window).height();
var bounds = {};
bounds.top = this.offset().top;
bounds.bottom = bounds.top + this.outerHeight();
return ( ! (
(bounds.top <= viewport.top) ||
(bounds.bottom >= viewport.bottom)
) );
};
if( !$('li.toctree-l1.current').isFullyWithinViewport() ) {
$('.wy-nav-side')
.scrollTop(
$('li.toctree-l1.current').offset().top -
$('.wy-nav-side').offset().top -
60
);
}
......@@ -3,6 +3,8 @@ repo_url: https://github.com/civicrm/civicrm-dev-docs
site_description: A guide for CiviCRM developers.
site_author: The CiviCRM community
theme: readthedocs
extra_javascript:
- js/custom.js
markdown_extensions:
- markdown.extensions.admonition
pages:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment