]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
make subnav fix
authorJacob Thornton <jacobthornton@gmail.com>
Wed, 25 Jan 2012 01:13:02 +0000 (17:13 -0800)
committerJacob Thornton <jacobthornton@gmail.com>
Wed, 25 Jan 2012 01:13:02 +0000 (17:13 -0800)
docs/assets/css/docs.css
docs/assets/js/application.js

index d78cea2b1900a4dcc9d6bf97e515cefe24055c48..4ab3530695d5760e860ae66c70b0e5ea3348149a 100644 (file)
@@ -165,6 +165,12 @@ section {
   border-right: 0;
 }
 
+.subhead .subnav-fixed {
+  position: fixed;
+  top: 40px;
+  z-index:1000;
+}
+
 
 /* Quick links
 -------------------------------------------------- */
index 95caa0f31afa3d1ad79453da975f82dee51a55ec..4b7efe53fcccbc43a0844775ddaff2c7917078a8 100644 (file)
@@ -116,6 +116,27 @@ $(function(){
     })
   })
 
+  // fix sub nav playa
+  var $win = $(window)
+    , $nav = $('.subhead .nav')
+    , navTop = $('.subhead .nav').offset().top - 40
+    , isFixed = 0
+
+  processScroll()
+
+  $win.on('scroll', processScroll)
+
+  function processScroll() {
+    var i, scrollTop = $win.scrollTop()
+    if (scrollTop >= navTop && !isFixed) {
+      isFixed = 1
+      $nav.addClass('subnav-fixed')
+    } else if (scrollTop <= navTop && isFixed) {
+      isFixed = 0
+      $nav.removeClass('subnav-fixed')
+    }
+  }
+
 })
 
 // JS for javascript demos