-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
139 lines (116 loc) · 4.67 KB
/
test.html
File metadata and controls
139 lines (116 loc) · 4.67 KB
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
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title>Example Title</title>
<meta name="author" content="Your Name">
<meta name="description" content="Example description">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/test.css">
<link rel="icon" type="image/x-icon" href=""/>
</head>
<body>
<header></header>
<main>
<div class="card-section">
<h1>Your Selection</h1>
<h4>Premium Content based on your personal viewing habits</h4>
<div class="card-list">
<div class="card">
<img src="https://images.unsplash.com/photo-1433446787703-42d5bf446876?w=320"/>
</div>
<div class="card">
<img src="https://images.unsplash.com/photo-1584645511189-2a471d586ac2?w=320"/>
</div>
<div class="card">
<img src="https://images.unsplash.com/photo-1580237754524-f26ed36fa85c?w=320"/>
</div>
<div class="card">
<img src="https://images.unsplash.com/photo-1583132648336-a4f3a079a526?w=320"/>
</div>
<div class="card">
<img src="https://images.unsplash.com/photo-1468082547792-d37c6c74003e?w=320"/>
</div>
</div>
</div>
<div class="card-section">
<h1>More Items</h1>
<h4>Hover over the picture to get an awesome 3d parallax effect</h4>
<div class="card-list">
<div class="card">
<img src="https://images.unsplash.com/photo-1509316785289-025f5b846b35?w=320"/>
</div>
<div class="card">
<img src="https://images.unsplash.com/photo-1518365428912-757c887d86c0?w=320"/>
</div>
<div class="card">
<img src="https://images.unsplash.com/photo-1489573280374-2e193c63726c?w=320"/>
</div>
<div class="card">
<img src="https://images.unsplash.com/photo-1535190878546-79d24dae2530?w=320"/>
</div>
<div class="card">
<img src="https://images.unsplash.com/photo-1494675006433-9e9428eba6c7?w=320"/>
</div>
</div>
</div>
</main>
<footer></footer>
<script type="text/javascript">
var cards = $('.card');
cards.each( (index, card) => {
$(card).prepend("<div class='shineLayer'></div>")
});
$(".card").mousemove( function(event) {
var card = this;
var mouseCoord = {
x: event.offsetX,
y: event.offsetY
};
//cleanup
mouseCoord.x = mouseCoord.x < 0 ? 0 : mouseCoord.x;
mouseCoord.x = mouseCoord.x > $(card).width() ? $(card).width() : mouseCoord.x;
mouseCoord.y = mouseCoord.y < 0 ? 0 : mouseCoord.y;
mouseCoord.y = mouseCoord.y > $(card).height() ? $(card).height() : mouseCoord.y;
var transformCard = "scale3d(1.08, 1.08, 1.08) perspective(700px)";
transformCard += " ";
//rotateX between -9 and +9
transformCard += "rotateX(" + ( ( ( (mouseCoord.y / $(card).height()) * 18 ) - 9 )) + "deg)";
transformCard += " ";
//rotateY between -13 and +13
transformCard += "rotateY(" + ( ( ( (mouseCoord.x / $(card).width()) * 26 ) - 13 ) * -1 ) + "deg)";
transformCard += " ";
//translateX between -3 and +3
transformCard += "translateX(" + ( ( (mouseCoord.x / $(card).width()) * 6 ) - 3 ) + "px)";
transformCard += " ";
//translateY between -5 and +5
transformCard += "translateY(" + ( ( (mouseCoord.y / $(card).height()) * 10 ) - 5 ) + "px)";
$(card).css("transform", transformCard);
//rotateX between -5 and +5
var transformCardImage = "rotateX(" + ( ( ( (mouseCoord.y / $(card).height()) * 10 ) - 5 ) * -1 ) + "deg)";
transformCardImage += " ";
//rotateX between -13 and +13
transformCardImage += "rotateY(" + ( ( ( (mouseCoord.x / $(card).width()) * 26 ) - 13 ) * -1 ) + "deg)";
$(card).find("img").css("transform", transformCardImage);
//opacity of ShineLayer between 0.1 and 0.4
var backgroundShineLayerOpacity = ((mouseCoord.y / $(card).height()) * 0.3) + 0.1;
//bottom=0deg; left=90deg; top=180deg; right=270deg;
var backgroundShineLayerDegree = (Math.atan2(mouseCoord.y - ($(card).height()/2), mouseCoord.x - ($(card).width()/2)) * 180/Math.PI) - 90;
backgroundShineLayerDegree = backgroundShineLayerDegree < 0 ? backgroundShineLayerDegree += 360 : backgroundShineLayerDegree
var backgroundShineLayer = "linear-gradient(" + backgroundShineLayerDegree + "deg, rgba(255,255,255," + backgroundShineLayerOpacity + ") 0%, rgba(255,255,255,0) 80%)";
$(card).find(".shineLayer").css("background", backgroundShineLayer);
});
$(".card").mouseenter( function(event) {
$(".card").addClass("blur");
$(this).removeClass("blur");
});
$(".card").mouseleave( function(event) {
var card = this;
$(card).css("transform", "scale3d(1, 1, 1)");
$(card).find("img").css("transform", "");
$(card).find(".shineLayer").css("background", "linear-gradient(0deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0) 80%)");
$(".card").removeClass("blur");
});
</script>
</body>
</html>