-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
29 lines (23 loc) · 789 Bytes
/
index.js
File metadata and controls
29 lines (23 loc) · 789 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
25
26
27
28
29
const getRandomInt = (max, min = 0) => {
const minInt = Math.ceil(min);
const maxInt = Math.floor(max);
return Math.floor(Math.random() * (maxInt - minInt)) + minInt;
}
const links = [{link: 'WCLink', image: 'WCImage'}, {link: 'BLink', image: 'BImage'}]
links.forEach((l) => {
const linkEl = document.getElementById(l.link)
const imageEl = document.getElementById(l.image)
if (!linkEl || !imageEl) {
return;
}
linkEl.addEventListener('mouseenter', () => {
imageEl.style.right = `${getRandomInt(40, 20)}%`
imageEl.style.top = `${getRandomInt(50, 10)}%`
imageEl.style.transform = 'scale(1)'
imageEl.style.opacity = 1
})
linkEl.addEventListener('mouseleave', () => {
imageEl.style.transform = 'scale(0)'
imageEl.style.opacity = 0
})
})