-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (21 loc) · 777 Bytes
/
Copy pathscript.js
File metadata and controls
24 lines (21 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function $(elem, from = document) {
return from.querySelector(elem);
}
document.addEventListener('mousemove', function (event) {
const leftLink = $('#left-link');
const rightLink = $('#right-link');
if (event.clientX <= 50) {
leftLink.classList.remove('hidden');
leftLink.style.transform = 'translateX(0)';
} else {
leftLink.style.transform = 'translateX(-100%)';
setTimeout(() => leftLink.classList.add('hidden'), 300);
}
if (event.clientX >= window.innerWidth - 50) {
rightLink.classList.remove('hidden');
rightLink.style.transform = 'translateX(0)';
} else {
rightLink.style.transform = 'translateX(100%)';
setTimeout(() => rightLink.classList.add('hidden'), 300);
}
});