Difference between revisions of "Template:ETH Zurich"
m |
m |
||
Line 81: | Line 81: | ||
}); | }); | ||
− | $('# | + | $(function(){ // document ready |
− | + | 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