Team:SYSU-Software/hm-overview.js
From 2014.igem.org
(Difference between revisions)
Huangmin1012 (Talk | contribs) |
Huangmin1012 (Talk | contribs) |
||
Line 1: | Line 1: | ||
- | + | window.onload = function(){ | |
- | var count = | + | var count = 1, |
- | wheel = true; | + | wheel = true, |
+ | auto; | ||
document.getElementById('showpics').className = 'rotate'; | document.getElementById('showpics').className = 'rotate'; | ||
- | + | document..getElementById('bodyContent').className="hm-part1"; | |
- | document.getElementById('bodyContent').className="hm- | + | |
$(window).mousewheel(function(e, delta){ | $(window).mousewheel(function(e, delta){ | ||
- | + | switch(e,delta); | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
}); | }); | ||
+ | } | ||
+ | function switch(e, delta){ | ||
+ | if(wheel){ | ||
+ | wheel = false; | ||
+ | if(count==1 && delta>0){ | ||
+ | count=1; | ||
+ | } else if(count==4 && delta<0){ | ||
+ | count=4; | ||
+ | } else { | ||
+ | delta > 0 ? count-- : count++; | ||
+ | count = count%4 || 4; | ||
+ | } | ||
+ | document.getElementById('bodyContent').className = 'hm-part'+count; | ||
+ | setTimeout(function(){ | ||
+ | wheel = true; | ||
+ | }, 1500); | ||
+ | clearTimeout(auto); | ||
+ | auto = setTimeout(function(){ | ||
+ | switch('x', 1); | ||
+ | },2000) | ||
+ | } | ||
} | } |
Revision as of 13:23, 17 October 2014
window.onload = function(){ var count = 1, wheel = true, auto; document.getElementById('showpics').className = 'rotate'; document..getElementById('bodyContent').className="hm-part1"; $(window).mousewheel(function(e, delta){ switch(e,delta); }); } function switch(e, delta){ if(wheel){ wheel = false; if(count==1 && delta>0){ count=1; } else if(count==4 && delta<0){ count=4; } else { delta > 0 ? count-- : count++; count = count%4 || 4; } document.getElementById('bodyContent').className = 'hm-part'+count; setTimeout(function(){ wheel = true; }, 1500); clearTimeout(auto); auto = setTimeout(function(){ switch('x', 1); },2000) } }