-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
91 lines (78 loc) · 2.18 KB
/
Copy pathapp.js
File metadata and controls
91 lines (78 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
function getByClass(a,b){
if(a.getElementsByClassName){
return a.getElementsByClassName(b);
}
var arr = [];
var all = a.getElementsByTagName('*');
var re = RegExp("\\b"+b+"\\b","g");
for (var i = 0; i < all.length; i++) {
if(re.test(all[i].className)){
arr.push(all[i]);
}
};
return arr;
};
window.onload = function(){
var aLi=document.getElementsByTagName('ul')[0].getElementsByTagName('li');
var aBtn=getByClass(document, 'foot')[0].getElementsByTagName('a');
var oCaret=getByClass(document, 'caret')[0];
var aPos=[];
var timer=null;
var i=0;
for(i=0;i<aLi.length;i++){
aLi[i].index=i;
aPos[i]=aLi[i].offsetLeft;
aLi[i].style.left=aPos[i]+'px';
}
for(i=0;i<aLi.length;i++){
aLi[i].style.position='absolute';
}
aBtn[0].onclick=function(){
var i=aLi.length-1;
clearTimeout(timer);
function next(){
if(i>=aLi.length/2){
move(aLi[i],{left:900})
timer = setTimeout(next, 100);
i--;
}else{
timer=setTimeout(next2, 150);
};
};
function next2(){
if(i>=0){
move(aLi[i],{left:aPos[i]});
timer=setTimeout(next2, 100);
}
i--;
};
next();
aBtn[1].className='';
this.className='show';
move(oCaret,{left:this.offsetLeft+this.offsetWidth/2});
};
aBtn[1].onclick=function(){
var i = 0;
clearTimeout(timer);
function next(){
if(i<aLi.length/2){
move(aLi[i],{left:-200})
timer = setTimeout(next, 100);
i++;
}else{
timer=setTimeout(next2, 150);
};
};
function next2(){
if(i<aLi.length){
move(aLi[i],{left:aPos[i-aLi.length/2]})
timer=setTimeout(next2, 100);
}
i++;
};
next();
aBtn[0].className='';
this.className='show';
move(oCaret,{left:this.offsetLeft+this.offsetWidth/2});
};
};