This repository has been archived by the owner on Nov 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslider.js
71 lines (56 loc) · 1.64 KB
/
slider.js
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
let divs = document.getElementsByTagName("div");
for(let i in divs){
if( "object" != typeof divs[i]) continue;
console.log(divs[i]);
divs[i].style.left = `${(i) * 100}%`;
}
!function s(){
let interval = setTimeout(() => {
let main = document.getElementsByTagName("main")[0];
// 移除首元素
let firstChild = main.firstChild;
main.removeChild(main.firstChild);
// 添加到末尾
main.appendChild(firstChild);
// 处理 postion位置
for(let i in divs){
if( "object" != typeof divs[i]) continue;
console.log(divs[i]);
divs[i].style.left = `${(i) * 100 - 100}%`;
}
s();
}, 1500);
}()
/**
* constructor
*/
function Slider(){
let opts = {};
Slider.prototype.opts = null;
Slider.prototype.init = () => {};
Slider.prototype.slider = () => {};
}
function removeClass(selector, className) {
if (selector.className.indexOf(className) !== -1)
selector.className = selector.className.substring(0, selector.className.indexOf(className));
}
function addEventListener(component, motivation, callback) {
if (motivation === 'hover') {
return component.onmouseover = () => {
return callback();
};
}
if (motivation === 'mouseLeave') {
return component.onmouseleave = () => {
return callback();
};
}
if (motivation === 'click') {
return component.onclick = () => {
return callback();
};
}
}
function addStyle(styleSheet, selector, cssCode) {
styleSheet.innerText += selector + '{' + cssCode + '}';
}