-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
129 lines (113 loc) · 3.9 KB
/
main.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
function load2D_bg(){
var background = document.getElementById("background");
var range = 40;
var calcValue = function calcValue(a, b) {
return (a / b * range - range / 2).toFixed(1);
};
var timeout = void 0;
document.addEventListener('mousemove',
function(_ref) {
var x = _ref.x,
y = _ref.y;
if (timeout) {
window.cancelAnimationFrame(timeout);
}
timeout = window.requestAnimationFrame(function() {
var yValue = calcValue(y, window.innerHeight);
var xValue = calcValue(x, window.innerWidth);
background.style.backgroundPositionX = xValue * 1 -200+ "px ";
background.style.backgroundPositionY = (-yValue * 0.75-50 ) + "px";
})
},false);
}
function load2D_bg2(){
var background = document.getElementById("background2");
var range = 40;
var calcValue = function calcValue(a, b) {
return (a / b * range - range / 2).toFixed(1);
};
var timeout = void 0;
document.addEventListener('mousemove',
function(_ref) {
var x = _ref.x,
y = _ref.y;
if (timeout) {
window.cancelAnimationFrame(timeout);
}
timeout = window.requestAnimationFrame(function() {
var yValue = calcValue(y, window.innerHeight);
var xValue = calcValue(x, window.innerWidth);
background.style.backgroundPositionX = xValue *1 -200+ "px ";
background.style.backgroundPositionY = (-yValue * 0.75-50 ) + "px";
})
},false);
}
function load2D_bg2_2(){
var background = document.getElementById("background2");
document.onmousemove=function(){
console.log(window.outerHeight);
background.style.opacity=1-(getMousePos()/window.outerHeight*2.5);
}
}
function getMousePos(event) {
var e = event || window.event;
var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
var y = e.pageY || e.clientY + scrollY;
return y;
}
function load2D_lihui(){
var background = document.getElementById("lihui");
var range = 40;
var calcValue = function calcValue(a, b) {
return (a / b * range - range / 2).toFixed(1);
};
var timeout = void 0;
document.addEventListener('mousemove',
function(_ref) {
var x = _ref.x,
y = _ref.y;
if (timeout) {
window.cancelAnimationFrame(timeout);
}
timeout = window.requestAnimationFrame(function() {
var xValue = calcValue(x, window.innerWidth);
background.style.left = xValue * 0.7-100 + "px";
})
},false);
}
function load2D_yinghua(){
var background = document.getElementById("yinghua");
var range = 40;
var calcValue = function calcValue(a, b) {
return (a / b * range - range / 2).toFixed(1);
};
var timeout = void 0;
document.addEventListener('mousemove',
function(_ref) {
var x = _ref.x,
y = _ref.y;
if (timeout) {
window.cancelAnimationFrame(timeout);
}
timeout = window.requestAnimationFrame(function() {
var yValue = calcValue(y, window.innerHeight);
var xValue = calcValue(x, window.innerWidth);
background.style.backgroundPositionX = xValue * 1.5 -200+ "px ";
background.style.backgroundPositionY = (-yValue * 1-50 ) + "px";
})
},false);
}
var i=0;
function aboutMe(){
var slogan = document.getElementById("slogan");
var slogan2 = document.getElementById("slogan2");
if(i==0){
i=1;
slogan.style.height="100px";
slogan2.innerHTML="这里是热爱web的青年,初始web就对此热爱,欢迎来带我们的个人页面。";
} else {
i=0;
slogan.style.height="50px";
slogan2.innerHTML="如果奇迹有颜色,那么一定是橙色!";
}
}