Team:Groningen/Template/SCRIPTS/scrollmenu
From 2014.igem.org
(Difference between revisions)
Line 4: | Line 4: | ||
var newMenuHeight = 0; | var newMenuHeight = 0; | ||
$(window).scroll(function(){ | $(window).scroll(function(){ | ||
- | if( $(window).scrollTop() > menuIconsHeight) { | + | if( $(window).scrollTop() > menuIconsHeight+17) { |
// 17 is height of topbar | // 17 is height of topbar | ||
newMenuHeight = $(document).scrollTop()-menuIconsHeight-17; | newMenuHeight = $(document).scrollTop()-menuIconsHeight-17; | ||
$('.default .module.menu .content').css({position: 'absolute'}); | $('.default .module.menu .content').css({position: 'absolute'}); | ||
- | $('.default .module.menu .content').css('top', newMenuHeight); | + | $('.default .module.menu .content').css('top', newMenuHeight + 'px'); |
} else { | } else { |
Revision as of 12:22, 17 October 2014
$(document).ready(function () { var menuIconsHeight = $('.default .module.menu .item .icon').height(); var newMenuHeight = 0; $(window).scroll(function(){ if( $(window).scrollTop() > menuIconsHeight+17) { // 17 is height of topbar newMenuHeight = $(document).scrollTop()-menuIconsHeight-17; $('.default .module.menu .content').css({position: 'absolute'}); $('.default .module.menu .content').css('top', newMenuHeight + 'px'); } else { $('.default .module.menu .content').css({position: 'relative', top: '0px'}); } }) });