Team:NCTU Formosa/source/head
From 2014.igem.org
(Difference between revisions)
Line 76: | Line 76: | ||
}); | }); | ||
}) | }) | ||
+ | $(document).ready(function(){ | ||
+ | if ($(document).scrollTop() > 409) { | ||
+ | $('#toc').stop().css({ | ||
+ | position: 'fixed', | ||
+ | left: '15px' | ||
+ | }).animate({'top': '111px'}, 500); | ||
+ | } | ||
+ | var long = false, | ||
+ | dheight = $(document).height(), | ||
+ | wheight = $(window).height(); | ||
+ | if($('#toc').height()+100>wheight) { long=true; } | ||
+ | var away = false; | ||
+ | $(document).scroll(function() { | ||
+ | if ($(document).scrollTop() > dheight/2) { | ||
+ | if (!away) { | ||
+ | if (long){ | ||
+ | away = true; | ||
+ | $('#toc').stop().css({ | ||
+ | position: 'fixed', | ||
+ | left: '15px' | ||
+ | }).animate({'top': -22-$('#toc').height()+wheight+'px'}, 500); | ||
+ | }} | ||
+ | } else { | ||
+ | away = false; | ||
+ | if ($(document).scrollTop() < 431){ | ||
+ | $('#toc').stop().css({ | ||
+ | position: 'absolute', | ||
+ | left: '-265px' | ||
+ | }).animate({'top': '0px'}, 500); | ||
+ | } | ||
+ | else { | ||
+ | $('#toc').stop().css({ | ||
+ | position: 'fixed', | ||
+ | left: '15px' | ||
+ | }).animate({'top': '111px'}, 500); | ||
+ | } | ||
+ | } | ||
+ | }); | ||
$(window).resize(function() { | $(window).resize(function() { | ||
dheight = $(document).height(); | dheight = $(document).height(); |
Revision as of 12:57, 15 September 2014