-
Notifications
You must be signed in to change notification settings - Fork 0
/
bilibili.html
152 lines (113 loc) · 3.48 KB
/
bilibili.html
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
!
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/style.css" rel="stylesheet">
</head>
<script crossorigin="anonymous"
integrity="sha512-h3aCJRk6tEHugDYUidF7GqixhzgeXSiSdq5U+5oLIJtIncSQq6eev48qqYfuTdrsH5Q1eO4IAmyJGDwzRaWNNQ=="
src="https://lib.baomitu.com/vue/2.6.12/vue.common.dev.js"></script>
<style>
body {
margin: 0px;
}
header {
height: 160px;
position: relative;
overflow: hidden;
}
header>div {
position: absolute;
top: 0px;
left: 0px;
right: 0px;
height: 100%;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
header>div>img {
display: block;
width: 110%;
height: 100%;
object-fit: cover;
transform: translatex(var(--move));
filter: blur(var(--blur));
}
</style>
<body>
<div id="app">
<header>
<div><img src="https://assets.codepen.io/2002878/bilibili-autumn-1.png"></div>
<div><img id="zhayan" src="https://assets.codepen.io/2002878/bilibili-autumn-2.png"></div>
<div><img src="https://assets.codepen.io/2002878/bilibili-autumn-3.png"></div>
<div><img src="https://assets.codepen.io/2002878/bilibili-autumn-4.png"></div>
<div><img src="https://assets.codepen.io/2002878/bilibili-autumn-5.png"></div>
<div><img src="https://assets.codepen.io/2002878/bilibili-autumn-6.png"></div>
</header>
</div>
</body>
<script>
new Vue({
el: '#app',
data: {
message: "jinx"
}
})
var isz = true;
let images = document.querySelectorAll('header > div > img')
function zhayan() {
let ele = document.getElementById('zhayan');
// ele.src = "biyan.png"
setTimeout(()=>{change1(ele)},150);
setTimeout(()=>{change2(ele)},300);
// setTimeout(()=>{change1(ele)},600);
setTimeout(()=>{change3(ele)},500);
isz = false;
return;
// setTimeout(ele.src = "biyan2.png",50)
// setTimeout(ele.src = "zyan.png",50)
};
function change1(ele){
ele.src="biyan.png"
};
function change2(ele){
ele.src="biyan2.png"
};
function change3(ele){
ele.src="zyan.png"
};
document.querySelector('header').addEventListener('mousemove', (e) => {
//坐标x
let percentage = e.clientX / window.outerWidth
///移动距离
let offset = 10 * percentage
//模糊度
let blur = 20
if(percentage<0.18||percentage>0.4){
//不在人物身上
isz=true;
console.log("不在人物身上")
}else if(percentage > 0.18 && percentage < 0.4){
//在人物身上
console.log("在人物身上"+isz)
if(isz){
console.log("执行眨眼");
zhayan();
}
}
for (let [index, image] of images.entries()) {
//最靠近屏幕前的图片移动距离最大
offset *= 1.3
//x的平方*20
let blurValue = (Math.pow((index / images.length - percentage), 2) * blur)
image.style.setProperty('--move', `${offset}px`)
image.style.setProperty('--blur', `${blurValue}px`)
}
})
</script>
</html>