Difference between revisions of "Template:ETH Zurich"

m
m
Line 81: Line 81:
 
});
 
});
  
$('#sidemenuContainer').scroll(function() {  
+
$(function(){ // document ready
    $('#sidemenu').css('top', $(this).scrollTop());
+
  if (!!$('#sidemenu').offset()) { // make sure ".sticky" element exists
 +
    var stickyTop = $('#sidemenu').offset().top; // returns number
 +
    $(window).scroll(function(){ // scroll event
 +
      var windowTop = $(window).scrollTop(); // returns number
 +
      if (stickyTop < windowTop){
 +
        $('#sidemenu').css({ position: 'fixed', top: 0 });
 +
      }
 +
      else {
 +
        $('#sidemenu').css('position','static');
 +
      }
 +
    });
 +
  }
 
});
 
});
  

Revision as of 16:26, 19 August 2015

We would like to thank our sponsors