mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 09:46:12 +00:00
initial commit
This commit is contained in:
commit
cb7f7afb93
27 changed files with 2606 additions and 0 deletions
41
lib/app.js
Normal file
41
lib/app.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
$(document).ready(function(){
|
||||
|
||||
// scroll spy logic
|
||||
// ================
|
||||
|
||||
var activeTarget,
|
||||
position = {},
|
||||
$window = $(window),
|
||||
nav = $('body > .topbar li a'),
|
||||
targets = nav.map(function () {
|
||||
return $(this).attr('href');
|
||||
}),
|
||||
offsets = $.map(targets, function (id) {
|
||||
return $(id).offset().top;
|
||||
});
|
||||
|
||||
|
||||
function setButton(id) {
|
||||
nav.parent("li").removeClass('active');
|
||||
$(nav[$.inArray(id, targets)]).parent("li").addClass('active');
|
||||
}
|
||||
|
||||
function processScroll(e) {
|
||||
var scrollTop = $window.scrollTop() + 10, i;
|
||||
for (i = offsets.length; i--;) {
|
||||
if (activeTarget != targets[i] && scrollTop >= offsets[i] && (!offsets[i + 1] || scrollTop <= offsets[i + 1])) {
|
||||
activeTarget = targets[i];
|
||||
setButton(activeTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nav.click(function () {
|
||||
processScroll();
|
||||
});
|
||||
|
||||
processScroll();
|
||||
|
||||
$window.scroll(processScroll);
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue