-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
33 lines (28 loc) · 1.12 KB
/
Copy pathscript.js
File metadata and controls
33 lines (28 loc) · 1.12 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
document.querySelectorAll('.link-card').forEach(card => {
card.addEventListener('click', function(e) {
const ripple = document.createElement('div');
const rect = this.getBoundingClientRect();
const size = Math.max(rect.width, rect.height);
const x = e.clientX - rect.left - size / 2;
const y = e.clientY - rect.top - size / 2;
ripple.style.width = ripple.style.height = size + 'px';
ripple.style.left = x + 'px';
ripple.style.top = y + 'px';
ripple.classList.add('ripple');
this.appendChild(ripple);
setTimeout(() => ripple.remove(), 600);
});
});
let currentCard = 0;
const cards = document.querySelectorAll('.link-card');
document.addEventListener('keydown', function(e) {
if (e.key === 'ArrowDown') {
e.preventDefault();
currentCard = (currentCard + 1) % cards.length;
cards[currentCard].focus();
} else if (e.key === 'ArrowUp') {
e.preventDefault();
currentCard = (currentCard - 1 + cards.length) % cards.length;
cards[currentCard].focus();
}
});