Skip to content

Commit b85cab0

Browse files
committed
2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave: Translation P.1
1 parent 93b1191 commit b85cab0

File tree

1 file changed

+39
-39
lines changed
  • 2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave

1 file changed

+39
-39
lines changed

2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/article.md

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,103 @@
1-
# Moving the mouse: mouseover/out, mouseenter/leave
1+
# Переміщення миші: mouseover/out, mouseenter/leave
22

3-
Let's dive into more details about events that happen when the mouse moves between elements.
3+
Давайте детальніше розглянемо події, які відбуваються, коли вказівник миші переміщається між елементами.
44

5-
## Events mouseover/mouseout, relatedTarget
5+
## Події mouseover/mouseout, relatedTarget
66

7-
The `mouseover` event occurs when a mouse pointer comes over an element, and `mouseout` -- when it leaves.
7+
Подія `mouseover` виникає, коли вказівник миші наводиться на елемент, а `mouseout` -- коли залишає його.
88

99
![](mouseover-mouseout.svg)
1010

11-
These events are special, because they have property `relatedTarget`. This property complements `target`. When a mouse leaves one element for another, one of them becomes `target`, and the other one - `relatedTarget`.
11+
Ці події особливі, оскільки мають властивість `relatedTarget`. Ця властивість доповнює `target`. Коли миша йде від одного елемента до іншого, один з них стає `target`, а інший -- `relatedTarget`.
1212

13-
For `mouseover`:
13+
Для `mouseover`:
1414

15-
- `event.target` -- is the element where the mouse came over.
16-
- `event.relatedTarget` -- is the element from which the mouse came (`relatedTarget` -> `target`).
15+
- `event.target` -- це елемент, на який наведено вказівник миші.
16+
- `event.relatedTarget` -- це елемент, з якого прийшов вказіник (`relatedTarget` -> `target`).
1717

18-
For `mouseout` the reverse:
18+
Для `mouseout` навпаки:
1919

20-
- `event.target` -- is the element that the mouse left.
21-
- `event.relatedTarget` -- is the new under-the-pointer element, that mouse left for (`target` -> `relatedTarget`).
20+
- `event.target` -- це елемент, який залишила миша.
21+
- `event.relatedTarget` -- це новий елемент під вказівником, на який перейшла миша (`target` -> `relatedTarget`).
2222

2323
```online
24-
In the example below each face and its features are separate elements. When you move the mouse, you can see mouse events in the text area.
24+
У наведеному нижче прикладі кожне обличчя та його риси є окремими елементами. Коли ви рухаєте мишею, події миші відображаються в текстовій області.
2525
26-
Each event has the information about both `target` and `relatedTarget`:
26+
Кожна подія містить інформацію як про `target`, так і про `relatedTarget`:
2727
2828
[codetabs src="mouseoverout" height=280]
2929
```
3030

31-
```warn header="`relatedTarget` can be `null`"
32-
The `relatedTarget` property can be `null`.
31+
```warn header="`relatedTarget` може бути `null`"
32+
Властивість `relatedTarget` може мати значення `null`.
3333

34-
That's normal and just means that the mouse came not from another element, but from out of the window. Or that it left the window.
34+
Це нормально і просто означає, що вказівник миші прийшов не з іншого елемента, а десь з вікна. Або навпаки, що вказівник вийшов за межі вікна браузера.
3535

36-
We should keep that possibility in mind when using `event.relatedTarget` in our code. If we access `event.relatedTarget.tagName`, then there will be an error.
36+
Нам варто пам'ятати про цю можливість, використовуючи `event.relatedTarget` в коді. Бо якщо спробувати отримати доступ до `event.relatedTarget.tagName`, то виникне помилка.
3737
```
3838
39-
## Skipping elements
39+
## Пропуск елементів
4040
41-
The `mousemove` event triggers when the mouse moves. But that doesn't mean that every pixel leads to an event.
41+
Подія `mousemove` запускається, коли миша рухається. Але це не означає, що кожен навіть найменший рух веде до окремої події.
4242
43-
The browser checks the mouse position from time to time. And if it notices changes then triggers the events.
43+
Час від часу браузер перевіряє положення миші. І якщо він помічає зміни, то запускає події.
4444
45-
That means that if the visitor is moving the mouse very fast then some DOM-elements may be skipped:
45+
Це означає, що якщо користувач рухає мишею дуже швидко, деякі DOM-елементи можуть бути пропущені:
4646
4747
![](mouseover-mouseout-over-elems.svg)
4848
49-
If the mouse moves very fast from `#FROM` to `#TO` elements as painted above, then intermediate `<div>` elements (or some of them) may be skipped. The `mouseout` event may trigger on `#FROM` and then immediately `mouseover` on `#TO`.
49+
Якщо миша дуже швидко рухається від елементів `#FROM` до `#TO`, як зазначено вище, то проміжні елементи `<div>` (або деякі з них) можуть бути пропущені. Подія `mouseout` може бути ініційована на `#FROM`, а потім одразу `mouseover`на `#TO`.
5050
51-
That's good for performance, because there may be many intermediate elements. We don't really want to process in and out of each one.
51+
Це добре для продуктивності, бо може бути багато проміжних елементів. Ми насправді не хочемо обробляти кожен із них.
5252
53-
On the other hand, we should keep in mind that the mouse pointer doesn't "visit" all elements along the way. It can "jump".
53+
З іншого боку, ми повинні мати на увазі, що вказівник миші не "відвідує" всі елементи на шляху і може "стрибати".
5454
55-
In particular, it's possible that the pointer jumps right inside the middle of the page from out of the window. In that case `relatedTarget` is `null`, because it came from "nowhere":
55+
Зокрема, можливо, що вказівник стрибне прямо всередину сторінки з поза меж вікна. У цьому випадку `relatedTarget` має значення `null`, тому що він прийшов "нізвідки":
5656
5757
![](mouseover-mouseout-from-outside.svg)
5858
5959
```online
60-
You can check it out "live" on a teststand below.
60+
Ви можете перевірити це на тестовому стенді нижче.
6161
62-
Its HTML has two nested elements: the `<div id="child">` is inside the `<div id="parent">`. If you move the mouse fast over them, then maybe only the child div triggers events, or maybe the parent one, or maybe there will be no events at all.
62+
Його HTML має два вкладені елементи: `<div id="child">` знаходиться всередині `<div id="parent">`. Якщо ви швидко наведете на них мишу, то, можливо, лише дочірній div ініціює події, або батьківський, або навіть подій не буде взагалі.
6363
64-
Also move the pointer into the child `div`, and then move it out quickly down through the parent one. If the movement is fast enough, then the parent element is ignored. The mouse will cross the parent element without noticing it.
64+
Також перемістіть вказівник у дочірній `div`, а потім швидко перемістіть його вниз через батьківський. Якщо рух досить швидкий, то батьківський елемент ігнорується. Миша перетне батьківський елемент, не помітивши цього.
6565
6666
[codetabs height=360 src="mouseoverout-fast"]
6767
```
6868

69-
```smart header="If `mouseover` triggered, there must be `mouseout`"
70-
In case of fast mouse movements, intermediate elements may be ignored, but one thing we know for sure: if the pointer "officially" entered an element (`mouseover` event generated), then upon leaving it we always get `mouseout`.
69+
```smart header="If `Якщо спрацьовує `mouseover`, має бути `mouseout`"
70+
У разі швидких рухів миші проміжні елементи можуть ігноруватися, але одне ми знаємо напевно: якщо вказівник "офіційно" увійшов на елемент (генерується подія `mouseover`), то при виході з нього ми завжди отримуємо `mouseout`.
7171
```
7272
73-
## Mouseout when leaving for a child
73+
## Mouseout при переході на дочірній елемент
7474
75-
An important feature of `mouseout` -- it triggers, when the pointer moves from an element to its descendant, e.g. from `#parent` to `#child` in this HTML:
75+
Важлива функція події `mouseout` -- вона запускається, коли вказівник переміщується від елемента до його нащадка, наприклад, від `#parent` до `#child` у HTML нижче:
7676
7777
```html
7878
<div id="parent">
7979
<div id="child">...</div>
8080
</div>
8181
```
8282

83-
If we're on `#parent` and then move the pointer deeper into `#child`, we get `mouseout` on `#parent`!
83+
Якщо ми знаходимося на `#parent`, а потім переміщуємо вказівник глибше в `#child`, ми отримуємо `mouseout` на `#parent`!
8484

8585
![](mouseover-to-child.svg)
8686

87-
That may seem strange, but can be easily explained.
87+
Це може здатися дивним, але це легко пояснити.
8888

89-
**According to the browser logic, the mouse cursor may be only over a *single* element at any time -- the most nested one and top by z-index.**
89+
**Відповідно до логіки браузера, вказівник миші може бути лише над *одним* елементом у будь-який момент часу -- найбільш вкладеним і верхнім за z-індексом.**
9090

91-
So if it goes to another element (even a descendant), then it leaves the previous one.
91+
Отже, якщо він переходить до іншого елемента (навіть до нащадка), то він залишає попередній.
9292

93-
Please note another important detail of event processing.
93+
Зверніть увагу на ще одну важливу деталь обробки подій.
9494

95-
The `mouseover` event on a descendant bubbles up. So, if `#parent` has `mouseover` handler, it triggers:
95+
Подія `mouseover` на нащадку буде спливати. Отже, якщо `#parent` має обробник `mouseover`, він спрацює:
9696

9797
![](mouseover-bubble-nested.svg)
9898

9999
```online
100-
You can see that very well in the example below: `<div id="child">` is inside the `<div id="parent">`. There are `mouseover/out` handlers on `#parent` element that output event details.
100+
Ви можете це добре побачити в прикладі нижче: `<div id="child">` знаходиться всередині `<div id="parent">`. І обробники `mouseover/out` для елементу `#parent` виведуть деталі події.
101101
102102
If you move the mouse from `#parent` to `#child`, you see two events on `#parent`:
103103
1. `mouseout [target: parent]` (left the parent), then

0 commit comments

Comments
 (0)