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
function toIntArray(v) {
const ret = [];
const version = v.split('.');
for (let i = 0; i < version.length; i++) {
ret.push(parseInt(version[i], 10));
}
return ret;
}
const calcScrollLeft = (windowWidth, tabWidth, current) => {
let scrollInit = current * windowWidth * tabWidth;
if (current <= 2) {
scrollInit = 0;
} else {
scrollInit = (current - 2) * windowWidth * tabWidth;
}
return scrollInit;
};
const compareVersion = (v) => {
const targetVersion = toIntArray('1.10.0');
const version = toIntArray(v);
let ret = 0;
for (let i = 0, n1, n2; i < version.length; i++) {
n1 = targetVersion[i];
n2 = version[i];
if (n1 > n2) {
ret = -1;
break
}
if (n1 < n2) {
ret = 1;
break;
}
}
return ret;
}
export default {
calcScrollLeft,
compareVersion,
};