1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-28 14:29:07 +02:00

some progress on affix plugin

This commit is contained in:
Jacob Thornton
2012-07-22 18:28:39 -07:00
parent fa1e1e34df
commit dcf75697ec
39 changed files with 503 additions and 221 deletions

View File

@@ -43,32 +43,6 @@
})
}
// fix sub nav on scroll
var $win = $(window)
, $nav = $('.subhead .navbar-subnav')
, navTop = $('.subhead .navbar-subnav').length && $('.subhead .navbar-subnav').offset().top - 40
, isFixed = 0
processScroll()
// hack sad times - holdover until rewrite for 2.1
$nav.on('click', function () {
if (!isFixed) setTimeout(function () { $win.scrollTop($win.scrollTop() - 47) }, 10)
})
$win.on('scroll', processScroll)
function processScroll() {
var i, scrollTop = $win.scrollTop()
if (scrollTop >= navTop && !isFixed) {
isFixed = 1
$nav.addClass('navbar-subnav-fixed')
} else if (scrollTop <= navTop && isFixed) {
isFixed = 0
$nav.removeClass('navbar-subnav-fixed')
}
}
// tooltip demo
$('.tooltip-demo').tooltip({
selector: "a[rel=tooltip]"