Team:NCTU Formosa/source/head
From 2013.igem.org
(Difference between revisions)
Line 77: | Line 77: | ||
}) | }) | ||
$(document).ready(function(){ | $(document).ready(function(){ | ||
- | if ($(document).scrollTop() > | + | if ($(document).scrollTop() > 409) { |
$('#toc').stop().css({ | $('#toc').stop().css({ | ||
position: 'fixed', | position: 'fixed', | ||
- | left: ' | + | left: '15px' |
- | }).animate({'top': ' | + | }).animate({'top': '111px'}, 500); |
} | } | ||
- | if ($(document).scrollTop() < | + | 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({ | $('#toc').stop().css({ | ||
position: 'absolute', | position: 'absolute', | ||
Line 92: | Line 109: | ||
$('#toc').stop().css({ | $('#toc').stop().css({ | ||
position: 'fixed', | position: 'fixed', | ||
- | left: ' | + | left: '15px' |
- | }).animate({'top': ' | + | }).animate({'top': '111px'}, 500); |
} | } | ||
} | } |
Latest revision as of 13:28, 15 September 2014