Difference between revisions of "Team:NUDT CHINA"

Line 21: Line 21:
 
contentAuto();
 
contentAuto();
 
mouseWheel();
 
mouseWheel();
touchMove();
 
 
bindNav();
 
bindNav();
 
add1();
 
add1();
Line 33: Line 32:
 
function add2() {
 
function add2() {
 
btn1.onclick=function () {
 
btn1.onclick=function () {
toMove(1)
+
toMove(1);
 +
iNow=1;
 
}
 
}
 
btn2.onclick=function () {
 
btn2.onclick=function () {
toMove(2)
+
toMove(2);
 +
iNow=2;
 
}
 
}
 
}
 
}
Line 44: Line 45:
 
if(oContent.addEventListener){
 
if(oContent.addEventListener){
 
oContent.addEventListener('DOMMouseScroll',function(ev){
 
oContent.addEventListener('DOMMouseScroll',function(ev){
var ev = ev || window.event;
 
clearTimeout(timer);
 
timer = setTimeout(function(){
 
toChange(ev);
 
},200);
 
},false);
 
}
 
oContent.onmousewheel = function(ev){
 
var ev = ev || window.event;
 
clearTimeout(timer);
 
timer = setTimeout(function(){
 
toChange(ev);
 
},200);
 
};
 
 
function toChange(ev){
 
if(ev.detail){
 
bBtn = ev.detail > 0 ? true : false;
 
}
 
else{
 
bBtn = ev.wheelDelta < 0 ? true : false;
 
}
 
 
if(  iNow == aLiList.length-1){if(bBtn!=0){return;};}
 
if( iNow == 0 ){if(bBtn==0){return;};}
 
 
prevIndex = iNow;
 
if(bBtn){  //↓
 
if(iNow != aLiList.length-1){
 
iNow++;
 
}
 
toMove(iNow);
 
}
 
else{  //↑
 
if(iNow != 0){
 
iNow--;
 
}
 
toMove(iNow);
 
}
 
 
if(ev.preventDefault){
 
ev.preventDefault();
 
}
 
else{
 
return false;
 
}
 
}
 
 
}
 
 
function touchMove(){
 
var bBtn = true;
 
var timer = null;
 
if(oContent.addEventListener){
 
oContent.addEventListener('touchmove',function(ev){
 
 
var ev = ev || window.event;
 
var ev = ev || window.event;
 
clearTimeout(timer);
 
clearTimeout(timer);

Revision as of 11:53, 25 October 2017

Team:NUDT_CHINA