You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1.Wrap every tree node title into `<span>`. Then we can CSS-style them on `:hover` and handle clicks exactly on text, because `<span>` width is exactly the text width (unlike without it).
4
-
2.Set a handler to the `tree` root node and handle clicks on that `<span>` titles.
3
+
1.트리에 있는 모든 텍스트를 `<span>`이 감싸도록 합니다. 이렇게 하면 CSS`:hover`를 사용해 마우스 오버 시 글씨를 굴게 해주는 효과를 줄 수 있고 `<span>`이 차지하는 너비가 텍스트의 너비와 정확히 일치하기 때문에 텍스트에만 클릭 이벤트가 동작하도록 할 수 있습니다.
Copy file name to clipboardExpand all lines: 2-ui/2-events/03-event-delegation/4-behavior-tooltip/task.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,35 +4,35 @@ importance: 5
4
4
5
5
# Tooltip behavior
6
6
7
-
Create JS-code for the tooltip behavior.
7
+
툴팁(tooltip)을 보여주는 JS 코드를 작성해봅시다.
8
8
9
-
When a mouse comes over an element with `data-tooltip`, the tooltip should appear over it, and when it's gone then hide.
9
+
`data-tooltip` 속성이 있는 요소에 마우스를 가져다 대면 툴팁이 보여야 하고, 마우스 커서가 요소에서 떠나면 툴팁이 사라져야 합니다.
10
10
11
-
An example of annotated HTML:
11
+
`data-tooltip` 속성은 다음 HTML처럼 추가할 수 있습니다.
12
12
```html
13
13
<buttondata-tooltip="the tooltip is longer than the element">Short button</button>
14
-
<buttondata-tooltip="HTML<br>tooltip">One more button</button>
14
+
<buttondata-tooltip="두 줄짜리<br>툴팁">...또 다른 버튼...</button>
15
15
```
16
16
17
17
Should work like this:
18
18
19
19
[iframe src="solution" height=200 border=1]
20
20
21
-
In this task we assume that all elements with `data-tooltip` have only text inside. No nested tags (yet).
21
+
`data-tooltip`이 있는 요소엔 텍스트만 있다고 가정하겠습니다. 요소 안에 다른 태그가 있는 경우는 생각하지 않기로 합시다.
22
22
23
23
Details:
24
24
25
-
-The distance between the element and the tooltip should be `5px`.
26
-
-The tooltip should be centered relative to the element, if possible.
25
+
-툴팁과 요소의 간격은 `5px`입니다.
26
+
-가능하면 툴팁은 요소를 기준으로 중앙에 있도록 합시다.
27
27
- The tooltip should not cross window edges. Normally it should be above the element, but if the element is at the page top and there's no space for the tooltip, then below it.
28
-
-The tooltip content is given in the `data-tooltip`attribute. It can be arbitrary HTML.
28
+
-툴팁안에 띄울 콘텐츠는 `data-tooltip`속성에서 가져옵니다. 속성값은 HTML일 수 있습니다.
29
29
30
30
You'll need two events here:
31
-
-`mouseover`triggers when a pointer comes over an element.
32
-
-`mouseout` triggers when a pointer leaves an element.
31
+
-`mouseover`-- 요소 안으로 포인터가 이동할 때 발생하는 이벤트
32
+
-`mouseout`-- 요소 밖으로 포인터가 이동할 때 발생하는 이벤트
33
33
34
-
Please use event delegation: set up two handlers on`document` to track all "overs" and "outs" from elements with `data-tooltip` and manage tooltips from there.
34
+
이벤트 위임을 사용해서 두 개의 핸들러만으로 원하는 기능을 구현하세요.`document`에 핸들러를 추가해 `data-tooltip` 속성이 있는 요소 안이나 밖으로 마우스 포인터가 이동하는 경우를 모두 감지하고 두 핸들러를 통해 툴팁을 보여주거나 감추시면 됩니다.
35
35
36
36
After the behavior is implemented, even people unfamiliar with JavaScript can add annotated elements.
0 commit comments