Team:NCTU Formosa/source/head
From 2014.igem.org
(Difference between revisions)
(7 intermediate revisions not shown) | |||
Line 80: | Line 80: | ||
$('#toc').stop().css({ | $('#toc').stop().css({ | ||
position: 'fixed', | position: 'fixed', | ||
+ | top: '10px', | ||
left: '-265px' | left: '-265px' | ||
- | } | + | }); |
} | } | ||
+ | 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', | ||
+ | top: '0px', | ||
+ | left: '-265px' | ||
+ | }).animate({'top': -22-$('#toc').height()+wheight+'px'}, 500); | ||
+ | }} | ||
+ | } else { | ||
+ | away = false; | ||
if ($(document).scrollTop() < 140){ | if ($(document).scrollTop() < 140){ | ||
$('#toc').stop().css({ | $('#toc').stop().css({ | ||
position: 'absolute', | position: 'absolute', | ||
- | left: '- | + | top: '0px', |
- | } | + | left: '-465px' |
+ | }); | ||
} | } | ||
else { | else { | ||
$('#toc').stop().css({ | $('#toc').stop().css({ | ||
position: 'fixed', | position: 'fixed', | ||
+ | top: '10px', | ||
left: '-265px' | left: '-265px' | ||
- | } | + | }); |
} | } | ||
} | } |
Latest revision as of 17:14, 15 September 2014