-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
145 lines (131 loc) · 4.09 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>Choose</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
*{
cursor: none;
}
body{
overflow: hidden;
}
:root{
--text-size: 14px;
--pixel-size: 2px;
--tile: calc(var(--pixel-size) * 16);
--bg: #9fa7e4;
}
@media(min-width: 700px){
:root{
--pixel-size: 3px;
--text-size: 15px;
}
#cursor{
display: block;
}
}
@media(min-width: 1000px){
:root{
--pixel-size: 5px;
--text-size: 20px;
}
}
@media(min-width: 1400px){
:root{
--pixel-size: 6px;
--text-size: 24px;
}
}
#cursor{
top: 2%;
left: 1%;
width: calc( var(--tile) * 0.7);
position: absolute;
z-index: 3;
display: block;
transform: translate(-50%, -50%);
pointer-events: none;
}
#cursorhandContainer{
top: 0%;
left: 0%;
height: calc(var(--tile));
position: absolute;
z-index: 3;
display: block;
transform: translate(-50%, -50%);
pointer-events: none;
}
#cursorhand{
height: 100% !important;
}
@media(min-width: 700px){
#cursor{
display: block;
}
}
.pixel{
image-rendering:-moz-crisp-edges; /* Firefox */
image-rendering:-o-crisp-edges; /* Opera */
image-rendering:-webkit-optimize-contrast; /* Safari */
image-rendering:optimize-contrast; /* CSS3 Proposed */
image-rendering:crisp-edges; /* CSS4 Proposed */
image-rendering:pixelated; /* CSS4 Proposed */
-ms-interpolation-mode:nearest-neighbor; /* IE8+ */
}
</style>
</head>
<body>
<div id="cursor">
<img src="images/carrot/carrot_cursor_happy.png" id="cursorImage" draggable="false" style="width: 100%; height: 100%;" class="pixel" />
<div id="cursorhandContainer">
<img id="cursorhand" src="images/carrot/hand.png" class="pixel" alt="" style="transform: rotateZ(90deg); opacity: 0.7;">
</div>
</div>
<div class="h-screen w-screen flex flex-col md:flex-row bg-black text-white overflow-x-hidden">
<a href="playable/index.html" class="h-full w-full bg-red-400 flex justify-center flex-col" onmouseover="changeCursorImage('carrot_cursor_happy')" >
<div class="w-full text-center text-3xl" id="playable">Playable Portfolio</div>
</a>
<a href="standard/index.html" class="h-full w-full bg-blue-400 flex justify-center flex-col" onmouseover="changeCursorImage('carrot_cursor_hat')">
<div class="w-full text-center text-3xl">Standard Portfolio</div>
</a>
<a href="nerd/index.html" class="h-full w-full bg-yellow-400 flex justify-center flex-col" onmouseover="changeCursorImage('carrot_cursor_nerd2')">
<div class="w-full text-center text-3xl">Nerd Portfolio</div>
</a>
</div>
</body>
<script>
let mouseCursor = document.querySelector("#cursor");
let mouseCursorhandContainer = document.querySelector("#cursorhandContainer");
let mouseCursorImage = document.querySelector("#cursorImage");
window.addEventListener("mousemove", cursor);
function cursor(e) {
mouseCursor.style.top = e.pageY + "px"
mouseCursor.style.left = e.pageX + "px"
rect = document.getElementById("playable").getBoundingClientRect();
pos = {x: rect.left+((rect.right - rect.left)/2), y: rect.top+((rect.bottom - rect.top)/2)}
// angle in degrees
var angleDeg = Math.atan2(pos.y - e.pageY, pos.x - e.pageX) * 180 / Math.PI;
mouseCursorhandContainer.style.transform = `rotate(${angleDeg}deg)`
}
document.addEventListener("mouseleave", function(event){
if(event.clientY <= 0 || event.clientX <= 0 || (event.clientX >= window.innerWidth || event.clientY >= window.innerHeight))
{
mouseCursor.style.display= "none";
}
});
document.addEventListener("mouseenter", function(event){
if(event.clientY >= 0 || event.clientX >= 0 || (event.clientX <= window.innerWidth || event.clientY <= window.innerHeight))
{
mouseCursor.style.display= "block";
}
});
window.onresize = function() {
pixelSize = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--pixel-size'));
};
function changeCursorImage(image){
mouseCursorImage.src = `images/carrot/${image}.png`
}
</script>
</html>