Team:HIT-Harbin/js/main.js
From 2014.igem.org
Line 13: | Line 13: | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
Revision as of 15:45, 17 October 2014
function sideMenu(x){ var arr=document.getElementsByName("rnav"); var y=x-1; for(var i=0;i<6;i++){
if(i==y){ arr[i].style.display = "block";
}
else{ arr[i].style.display = "none";
} } }
$(document).ready(function() {
$.preloadImages = function() {
for(var i = 0; i<arguments.length; i++) { $("<img />").attr("src", arguments[i]); }
}
$.preloadImages("images/toparrow.png","images/bottomarrow.png");
var $top1= $('#minibar').offset().top + 20;
var $mid1 = Math.floor($(window).height() / 2);
$('#dirbutton').data('mode','scrollup');
$('#dirbutton').click(function()
{
$mode = $(this).data('mode'); switch($mode) { case 'scrolldown':
$('html, body').animate({scrollTop:0}, 'slow'); return false; break; case 'scrollup': $scrollpos = $('body').outerHeight(); $('html, body').animate({scrollTop:$scrollpos}, 'slow'); return false; break;
}
});
$(window).scroll(function() {
if ($(window).scrollTop()>$top1) { $('#nav').hide(); $('#minibar').show(); $('#minibar').addClass('nav'); } else { $('#minibar').hide(); $('#nav').show();
}
if($(window).scrollTop() > $mid1)
{
$('#dirbutton').find('img').attr('src','images/toparrow.png');
$('#dirbutton').data('mode','scrolldown');
$('#dirbutton').show();
}else
{
$('#dirbutton').find('img').attr('src','images/bottomarrow.png');
$('#dirbutton').data('mode','scrollup');
} });
});