-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
31 lines (25 loc) · 1.05 KB
/
main.js
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
const reactions = document.getElementsByClassName('react');
const hoverContainer = document.getElementById('mouseover-container');
for (let reaction of reactions) {
reaction.addEventListener('mouseover', (event) => {
let userArray = reaction.getAttribute('data-users').split(',');
for (let user of userArray) {
newUser = document.createElement('p');
newUser.innerText = user.replace('_', ' ');
hoverContainer.appendChild(newUser);
}
hoverContainer.style.top = event.pageY + 'px';
hoverContainer.style.left = event.pageX + 'px';
hoverContainer.classList.remove('hidden');
})
reaction.addEventListener('mousemove', (event) => {
hoverContainer.style.top = event.pageY + 'px';
hoverContainer.style.left = event.pageX + 'px';
})
reaction.addEventListener('mouseleave', () => {
while(hoverContainer.firstChild) {
hoverContainer.removeChild(hoverContainer.firstChild);
}
hoverContainer.classList.add('hidden');
})
}