Coordinates by jeneg · Pull Request #305 · javascript-tutorial/uk.javascript.info
18 changes: 9 additions & 9 deletions 2-ui/1-document/11-coordinates/1-find-point-coordinates/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
24 changes: 12 additions & 12 deletions 2-ui/1-document/11-coordinates/1-find-point-coordinates/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,24 @@ | ||
| importance: 5 | ||
| важливість: 5 | ||
|
|
||
| --- | ||
|
|
||
| # Find window coordinates of the field | ||
| # Знайти координати поля відносно вікна | ||
|
|
||
| In the iframe below you can see a document with the green "field". | ||
| У iframe нижче ви можете побачити документ із зеленим «полем». | ||
|
|
||
| Use JavaScript to find window coordinates of corners pointed by with arrows. | ||
| Використовуючи JavaScript, знайдіть координати кутів відносно вікна, на які вказано стрілками. | ||
|
|
||
| There's a small feature implemented in the document for convenience. A click at any place shows coordinates there. | ||
| Для зручності в документі реалізована невелика функція, яка показує координати кліку. | ||
|
|
||
| [iframe border=1 height=360 src="source" link edit] | ||
|
|
||
| Your code should use DOM to get window coordinates of: | ||
| Ваш код повинен використовувати DOM для отримання чотирьох пар координат відносно вікна: | ||
|
|
||
| 1. Upper-left, outer corner (that's simple). | ||
| 2. Bottom-right, outer corner (simple too). | ||
| 3. Upper-left, inner corner (a bit harder). | ||
| 4. Bottom-right, inner corner (there are several ways, choose one). | ||
| 1. Верхній лівий, зовнішній кут (це просто). | ||
| 2. Правий нижній, зовнішній кут (теж просто). | ||
| 3. Верхній лівий, внутрішній кут (трохи складніше). | ||
| 4. Правий нижній, внутрішній кут (є кілька способів, оберіть один). | ||
|
|
||
| The coordinates that you calculate should be the same as those returned by the mouse click. | ||
| Обчислені координати повинні збігатися з тими, які повертаються клацанням миші. | ||
|
|
||
| P.S. The code should also work if the element has another size or border, not bound to any fixed values. | ||
| P.S. Код також повинен працювати, якщо елемент має інший розмір або рамку, тобто не прив’язаний до жодних фіксованих значень. |
6 changes: 3 additions & 3 deletions 2-ui/1-document/11-coordinates/2-position-at/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| In this task we only need to accurately calculate the coordinates. See the code for details. | ||
| У цьому завданні нам потрібно лише точно розрахувати координати. Подробиці дивіться в коді. | ||
|
|
||
| Please note: the elements must be in the document to read `offsetHeight` and other properties. | ||
| A hidden (`display:none`) or out of the document element has no size. | ||
| Зверніть увагу: елементи повинні бути в документі, щоб прочитати `offsetHeight` та інші властивості. | ||
| Прихований елемент (`display:none`) або елемент поза документом не має розміру. |
24 changes: 12 additions & 12 deletions 2-ui/1-document/11-coordinates/2-position-at/solution.view/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
26 changes: 13 additions & 13 deletions 2-ui/1-document/11-coordinates/2-position-at/source.view/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions 2-ui/1-document/11-coordinates/2-position-at/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,18 @@ | ||
| importance: 5 | ||
| важливість: 5 | ||
|
|
||
| --- | ||
|
|
||
| # Show a note near the element | ||
| # Покажіть примітку біля елемента | ||
|
|
||
| Create a function `positionAt(anchor, position, elem)` that positions `elem`, depending on `position` near `anchor` element. | ||
| Створіть функцію `positionAt(anchor, position, elem)`, яка позиціонує `elem` залежно від `position` біля елемента `anchor`. | ||
|
|
||
| The `position` must be a string with any one of 3 values: | ||
| - `"top"` - position `elem` right above `anchor` | ||
| - `"right"` - position `elem` immediately at the right of `anchor` | ||
| - `"bottom"` - position `elem` right below `anchor` | ||
| Аргумент `position` має бути рядком з будь-яким із 3 значень: | ||
| - `"top"` - розмістити `elem` праворуч над `anchor` | ||
| - `"right"` - розмістити `elem` безпосередньо праворуч від `anchor` | ||
| - `"bottom"` - розмістити `elem` прямо під `anchor` | ||
|
|
||
| It's used inside function `showNote(anchor, position, html)`, provided in the task source code, that creates a "note" element with given `html` and shows it at the given `position` near the `anchor`. | ||
| Аргумент використовується всередині функції `showNote(anchor, position, html)`, наданої у вихідному коді завдання, який створює елемент примітки із заданим `html` і показує його у заданій позиції `position` біля елементу `anchor`. | ||
|
|
||
| Here's the demo of notes: | ||
| Ось демонстрація приміток: | ||
|
|
||
| [iframe src="solution" height="350" border="1" link] |
6 changes: 3 additions & 3 deletions 2-ui/1-document/11-coordinates/3-position-at-absolute/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| The solution is actually pretty simple: | ||
| Рішення насправді досить просте: | ||
|
|
||
| - Use `position:absolute` in CSS instead of `position:fixed` for `.note`. | ||
| - Use the function [getCoords()](info:coordinates#getCoords) from the chapter <info:coordinates> to get document-relative coordinates. | ||
| - Використовуйте `position:absolute` у CSS замість `position:fixed` для елемента `.note`. | ||
| - Використовуйте функцію [getCoords()](info:coordinates#getCoords) з розділу <info:coordinates>, щоб отримати координати відносно документа. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions 2-ui/1-document/11-coordinates/3-position-at-absolute/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| importance: 5 | ||
| важливість: 5 | ||
|
|
||
| --- | ||
|
|
||
| # Show a note near the element (absolute) | ||
| # Покажіть примітку біля елемента (абсолютне позиціювання) | ||
|
|
||
| Modify the solution of the [previous task](info:task/position-at) so that the note uses `position:absolute` instead of `position:fixed`. | ||
| Скорегуйте рішення [попереднього завдання](info:task/position-at), щоб для позиціювання примітки використовувалася властивість `position:absolute` замість `position:fixed`. | ||
|
|
||
| That will prevent its "runaway" from the element when the page scrolls. | ||
| Це запобіжить «втечу» нотатки від елемента під час прокручування сторінки. | ||
|
|
||
| Take the solution of that task as a starting point. To test the scroll, add the style `<body style="height: 2000px">`. | ||
| Візьміть розв’язання попереднього завдання за відправну точку. Щоб перевірити прокрутку, додайте стиль `<body style="height: 2000px">`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
22 changes: 11 additions & 11 deletions 2-ui/1-document/11-coordinates/4-position-inside-absolute/task.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,28 @@ | ||
| importance: 5 | ||
| важливість: 5 | ||
|
|
||
| --- | ||
|
|
||
| # Position the note inside (absolute) | ||
| # Розташуйте примітку всередині елемента (абсолютне позиціювання) | ||
|
|
||
| Extend the previous task <info:task/position-at-absolute>: teach the function `positionAt(anchor, position, elem)` to insert `elem` inside the `anchor`. | ||
| Розширте попереднє завдання <info:task/position-at-absolute>: навчіть функцію `positionAt(anchor, position, elem)` вставляти `elem` всередині `anchor`. | ||
|
|
||
| New values for `position`: | ||
| Нові значення для `position`: | ||
|
|
||
| - `top-out`, `right-out`, `bottom-out` -- work the same as before, they insert the `elem` over/right/under `anchor`. | ||
| - `top-in`, `right-in`, `bottom-in` -- insert `elem` inside the `anchor`: stick it to the upper/right/bottom edge. | ||
| - `top-out`, `right-out`, `bottom-out` -- працюють так само як і раніше, вони вставляють `elem` над/праворуч/під елементом `anchor`. | ||
| - `top-in`, `right-in`, `bottom-in` -- вставляють `elem` всередину елемента `anchor`, та прикріпляють його до верхнього/правого/нижнього краю. | ||
|
|
||
| For instance: | ||
| Наприклад: | ||
|
|
||
| ```js | ||
| // shows the note above blockquote | ||
| // показує примітку над елементом blockquote | ||
| positionAt(blockquote, "top-out", note); | ||
|
|
||
| // shows the note inside blockquote, at the top | ||
| // показує примітку всередині елемента blockquote поряд з верхнім краєм | ||
| positionAt(blockquote, "top-in", note); | ||
| ``` | ||
|
|
||
| The result: | ||
| Результат: | ||
|
|
||
| [iframe src="solution" height="310" border="1" link] | ||
|
|
||
| As the source code, take the solution of the task <info:task/position-at-absolute>. | ||
| Для початку візьміть розв’язання задачі <info:task/position-at-absolute>. |