Difference between revisions of "Template:Exeter"

Line 410: Line 410:
 
</style>
 
</style>
  
<script type="text/javascript">
+
<script>
// Hide Header on on scroll down
+
$(document).ready(function() {
var didScroll;
+
 
var lastScrollTop = 0;
+
  $(window).scroll(function () {
var delta = 5;
+
      //if you hard code, then use console
var navbarHeight = $('nav').outerHeight();
+
      //.log to determine when you want the
 
+
      //nav bar to stick.
$(window).scroll(function(event){
+
      console.log($(window).scrollTop())
    didScroll = true;
+
     if ($(window).scrollTop() > 182) {
});
+
      $('.navbar-collapse').addClass('navbar-fixed-top');
 
+
setInterval(function() {
+
    if (didScroll) {
+
        hasScrolled();
+
        didScroll = false;
+
    }
+
}, 250);
+
 
+
function hasScrolled() {
+
    var st = $(this).scrollTop();
+
   
+
    // Make sure they scroll more than delta
+
    if(Math.abs(lastScrollTop - st) <= delta)
+
        return;
+
   
+
    // If they scrolled down and are past the navbar, add class .nav-up.
+
    // This is necessary so you never see what is "behind" the navbar.
+
    if (st > lastScrollTop && st > navbarHeight){
+
        // Scroll Down
+
        $('.navbar-collapse').addClass('nav-up').addClass('navbar-fixed-top');
+
     } else {
+
        // Scroll Up
+
        if(st + $(window).height() < $(document).height()) {
+
            $('.navbar-collapse').removeClass('nav-up');
+
        }
+
 
     }
 
     }
 
     if ($(window).scrollTop() < 183) {
 
     if ($(window).scrollTop() < 183) {
 
       $('.navbar-collapse').removeClass('navbar-fixed-top');
 
       $('.navbar-collapse').removeClass('navbar-fixed-top');
 
     }
 
     }
    lastScrollTop = st;
+
  });
}
+
});
 
</script>
 
</script>
  

Revision as of 22:08, 27 August 2015