Upload 4 files
Browse files
index.html
CHANGED
@@ -1,19 +1,54 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
|
4 |
+
<head>
|
5 |
+
<meta charset="UTF-8">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
8 |
+
<title>My Website</title>
|
9 |
+
<link rel="stylesheet" href="./style.css">
|
10 |
+
<link rel="icon" href="./favicon.ico" type="image/x-icon">
|
11 |
+
</head>
|
12 |
+
|
13 |
+
<body>
|
14 |
+
<div class="card blastoise">
|
15 |
+
<span class="inner-card-backface">
|
16 |
+
<span class="image">
|
17 |
+
<span class="unflip">Unflip</span>
|
18 |
+
</span>
|
19 |
+
</span>
|
20 |
+
<span class="inner-card">
|
21 |
+
<span class="flip">Flip</span>
|
22 |
+
<span class="glare"></span>
|
23 |
+
</span>
|
24 |
+
</div>
|
25 |
+
<div class="card user">
|
26 |
+
<span class="inner-card-backface">
|
27 |
+
<span class="flip-inner-card">
|
28 |
+
<h3>About</h3>
|
29 |
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis sit amet est nunc.</p>
|
30 |
+
<span class="unflip">Unflip</span>
|
31 |
+
</span>
|
32 |
+
</span>
|
33 |
+
<span class="inner-card">
|
34 |
+
<span class="user-details">
|
35 |
+
<span class="top-section">
|
36 |
+
<span class="flip">Flip</span>
|
37 |
+
</span>
|
38 |
+
<span class="bottom-section">
|
39 |
+
<span class="name">Zhuo Chen</span>
|
40 |
+
<span class="area"><span class="area-container">Engineering</span></span>
|
41 |
+
<span class="buttons">
|
42 |
+
<a href="https://openi.pcl.ac.cn" target="_blank" class="message">Message</a>
|
43 |
+
</span>
|
44 |
+
</span>
|
45 |
+
<span class="user-icon"><img src="./user.jpg" alt="" />
|
46 |
+
</span>
|
47 |
+
</span>
|
48 |
+
<span class="glare"></span>
|
49 |
+
</span>
|
50 |
+
</div>
|
51 |
+
<script src="index.js"></script>
|
52 |
+
</body>
|
53 |
+
|
54 |
+
</html>
|
index.js
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
let calculateAngle = function (e, item, parent) {
|
3 |
+
let dropShadowColor = `rgba(0, 0, 0, 0.3)`
|
4 |
+
if (parent.getAttribute('data-filter-color') !== null) {
|
5 |
+
dropShadowColor = parent.getAttribute('data-filter-color');
|
6 |
+
}
|
7 |
+
|
8 |
+
parent.classList.add('animated');
|
9 |
+
// Get the x position of the users mouse, relative to the button itself
|
10 |
+
let x = Math.abs(item.getBoundingClientRect().x - e.clientX);
|
11 |
+
// Get the y position relative to the button
|
12 |
+
let y = Math.abs(item.getBoundingClientRect().y - e.clientY);
|
13 |
+
|
14 |
+
// Calculate half the width and height
|
15 |
+
let halfWidth = item.getBoundingClientRect().width / 2;
|
16 |
+
let halfHeight = item.getBoundingClientRect().height / 2;
|
17 |
+
|
18 |
+
// Use this to create an angle. I have divided by 6 and 4 respectively so the effect looks good.
|
19 |
+
// Changing these numbers will change the depth of the effect.
|
20 |
+
let calcAngleX = (x - halfWidth) / 12;
|
21 |
+
let calcAngleY = (y - halfHeight) / 14;
|
22 |
+
|
23 |
+
let gX = (1 - (x / (halfWidth * 2))) * 100;
|
24 |
+
let gY = (1 - (y / (halfHeight * 2))) * 100;
|
25 |
+
|
26 |
+
item.querySelector('.glare').style.background = `radial-gradient(circle at ${gX}% ${gY}%, rgb(199 198 243), transparent)`;
|
27 |
+
// And set its container's perspective.
|
28 |
+
parent.style.perspective = `${halfWidth * 6}px`
|
29 |
+
item.style.perspective = `${halfWidth * 6}px`
|
30 |
+
|
31 |
+
// Set the items transform CSS property
|
32 |
+
item.style.transform = `rotateY(${calcAngleX}deg) rotateX(${-calcAngleY}deg) scale(1.04)`;
|
33 |
+
parent.querySelector('.inner-card-backface').style.transform = `rotateY(${calcAngleX}deg) rotateX(${-calcAngleY}deg) scale(1.04) translateZ(-4px)`;
|
34 |
+
|
35 |
+
if (parent.getAttribute('data-custom-perspective') !== null) {
|
36 |
+
parent.style.perspective = `${parent.getAttribute('data-custom-perspective')}`
|
37 |
+
}
|
38 |
+
|
39 |
+
// Reapply this to the shadow, with different dividers
|
40 |
+
let calcShadowX = (x - halfWidth) / 3;
|
41 |
+
let calcShadowY = (y - halfHeight) / 6;
|
42 |
+
|
43 |
+
// Add a filter shadow - this is more performant to animate than a regular box shadow.
|
44 |
+
item.style.filter = `drop-shadow(${-calcShadowX}px ${-calcShadowY}px 15px ${dropShadowColor})`;
|
45 |
+
}
|
46 |
+
|
47 |
+
document.querySelectorAll('.card').forEach(function (item) {
|
48 |
+
if (item.querySelector('.flip') !== null) {
|
49 |
+
item.querySelector('.flip').addEventListener('click', function () {
|
50 |
+
item.classList.add('flipped');
|
51 |
+
});
|
52 |
+
}
|
53 |
+
if (item.querySelector('.unflip') !== null) {
|
54 |
+
item.querySelector('.unflip').addEventListener('click', function () {
|
55 |
+
item.classList.remove('flipped');
|
56 |
+
});
|
57 |
+
}
|
58 |
+
item.addEventListener('mouseenter', function (e) {
|
59 |
+
calculateAngle(e, this.querySelector('.inner-card'), this);
|
60 |
+
});
|
61 |
+
|
62 |
+
item.addEventListener('mousemove', function (e) {
|
63 |
+
calculateAngle(e, this.querySelector('.inner-card'), this);
|
64 |
+
});
|
65 |
+
|
66 |
+
item.addEventListener('mouseleave', function (e) {
|
67 |
+
let dropShadowColor = `rgba(0, 0, 0, 0.3)`
|
68 |
+
if (item.getAttribute('data-filter-color') !== null) {
|
69 |
+
dropShadowColor = item.getAttribute('data-filter-color')
|
70 |
+
}
|
71 |
+
item.classList.remove('animated');
|
72 |
+
item.querySelector('.inner-card').style.transform = `rotateY(0deg) rotateX(0deg) scale(1)`;
|
73 |
+
item.querySelector('.inner-card-backface').style.transform = `rotateY(0deg) rotateX(0deg) scale(1.01) translateZ(-4px)`;
|
74 |
+
item.querySelector('.inner-card').style.filter = `drop-shadow(0 10px 15px ${dropShadowColor})`;
|
75 |
+
});
|
76 |
+
})
|
style.css
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
user.jpg
ADDED
![]() |