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

Merge pull request #42 from seanmadsen/41-nav-scroll

adding document-ready function to js
parents e79a5ffe c07ad2c6
No related branches found
No related tags found
No related merge requests found
$(function() {
// 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
);
}
// 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
);
}
});
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