Template:Team:Berkeley/scrollspyOffset.js
From 2013.igem.org
(Difference between revisions)
Line 1: | Line 1: | ||
+ | var offsetHeight = 51; | ||
- | + | $('body').scrollspy({ | |
+ | offset: offsetHeight | ||
+ | }); | ||
- | $('.navbar li a').click(function(event) { | + | $('.navbar li a').click(function (event) { |
- | + | var scrollPos = $('body > .container').find($(this).attr('href')).offset().top - (offsetHeight - 1); | |
- | + | $('body,html').animate({ | |
- | + | scrollTop: scrollPos | |
+ | }, 500, function () { | ||
+ | $(".btn-navbar").click(); | ||
+ | }); | ||
+ | return false; | ||
}); | }); |
Revision as of 01:49, 28 October 2013
var offsetHeight = 51;
$('body').scrollspy({
offset: offsetHeight
});
$('.navbar li a').click(function (event) {
var scrollPos = $('body > .container').find($(this).attr('href')).offset().top - (offsetHeight - 1); $('body,html').animate({ scrollTop: scrollPos }, 500, function () { $(".btn-navbar").click(); }); return false;
});