Skip to content

Commit 8626b82

Browse files
committed
2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave: Translation P.5
1 parent 7653c34 commit 8626b82

File tree

1 file changed

+18
-18
lines changed
  • 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/mouseenter-mouseleave-delegation-2.view

1 file changed

+18
-18
lines changed
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
1-
// <td> under the mouse right now (if any)
1+
// <td> під вказівником прямо зараз (якщо є)
22
let currentElem = null;
33

44
table.onmouseover = function(event) {
5-
// before entering a new element, the mouse always leaves the previous one
6-
// if currentElem is set, we didn't leave the previous <td>,
7-
// that's a mouseover inside it, ignore the event
5+
// перед переходом до нового елемента миша завжди залишає попередній
6+
// якщо вже встановлено currentElem, то ми не залишили попередній <td>,
7+
// і цей mouseover відбувається всередині, тому ігноруємо подію
88
if (currentElem) return;
99

1010
let target = event.target.closest('td');
1111

12-
// we moved not into a <td> - ignore
12+
// ми перейшли не в <td> - ігнорувати
1313
if (!target) return;
1414

15-
// moved into <td>, but outside of our table (possible in case of nested tables)
16-
// ignore
15+
// переміщено в <td>, але за межами нашої таблиці (можливо у випадку вкладених таблиць)
16+
// ігнорувати
1717
if (!table.contains(target)) return;
1818

19-
// hooray! we entered a new <td>
19+
// ура! ми перейщли до нового <td>
2020
currentElem = target;
2121
onEnter(currentElem);
2222
};
2323

2424

2525
table.onmouseout = function(event) {
26-
// if we're outside of any <td> now, then ignore the event
27-
// that's probably a move inside the table, but out of <td>,
28-
// e.g. from <tr> to another <tr>
26+
// якщо ми зараз поза будь-яким <td>, тоді ігноруємо подію
27+
// це, мабуть, переміщення всередину таблиці, але поза <td>,
28+
// напр. від <tr> до іншого <tr>
2929
if (!currentElem) return;
3030

31-
// we're leaving the element – where to? Maybe to a descendant?
31+
// покидаємо елемент – але куди? Може ідемо до дочірнього елемента?
3232
let relatedTarget = event.relatedTarget;
3333

3434
while (relatedTarget) {
35-
// go up the parent chain and check – if we're still inside currentElem
36-
// then that's an internal transition – ignore it
35+
// піднімаємось батьківським ланцюжком і перевіряємо – чи ми все ще всередині currentElem
36+
// тоді це внутрішній перехід – ігноруємо його
3737
if (relatedTarget == currentElem) return;
3838

3939
relatedTarget = relatedTarget.parentNode;
4040
}
4141

42-
// we left the <td>. really.
42+
// ми залишили <td>. насправді.
4343
onLeave(currentElem);
4444
currentElem = null;
4545
};
4646

47-
// any functions to handle entering/leaving an element
47+
// будь-які функції для обробки входу/виходу з елемента
4848
function onEnter(elem) {
4949
elem.style.background = 'pink';
5050

51-
// show that in textarea
51+
// показати це в textarea
5252
text.value += `over -> ${currentElem.tagName}.${currentElem.className}\n`;
5353
text.scrollTop = 1e6;
5454
}
5555

5656
function onLeave(elem) {
5757
elem.style.background = '';
5858

59-
// show that in textarea
59+
// показати це в textarea
6060
text.value += `out <- ${elem.tagName}.${elem.className}\n`;
6161
text.scrollTop = 1e6;
6262
}

0 commit comments

Comments
 (0)