Skip to content

Commit 1c27290

Browse files
committed
задание 1
1 parent e7c51e2 commit 1c27290

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

2-ui/1-document/11-coordinates/1-find-point-coordinates/solution.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Outer corners
1+
# Внешние углы
22

3-
Outer corners are basically what we get from [elem.getBoundingClientRect()](https://developer.mozilla.org/en-US/docs/DOM/element.getBoundingClientRect).
3+
Координаты внешних углов -- это как раз то, что возвращает функция [elem.getBoundingClientRect()](https://developer.mozilla.org/ru/docs/DOM/element.getBoundingClientRect).
44

5-
Coordinates of the upper-left corner `answer1` and the bottom-right corner `answer2`:
5+
Координаты верхнего левого внешнего угла будут в переменной `answer1` и нижнего правого -- в `answer2`:
66

77
```js
88
let coords = elem.getBoundingClientRect();
@@ -11,19 +11,19 @@ let answer1 = [coords.left, coords.top];
1111
let answer2 = [coords.right, coords.bottom];
1212
```
1313

14-
# Left-upper inner corner
14+
# Верхний левый внутренний угол
1515

16-
That differs from the outer corner by the border width. A reliable way to get the distance is `clientLeft/clientTop`:
16+
Тут значения отличаются на ширину рамки. Надёжный способ получить интересующее значение -- это использовать `clientLeft/clientTop`:
1717

1818
```js
1919
let answer3 = [coords.left + field.clientLeft, coords.top + field.clientTop];
2020
```
2121

22-
# Right-bottom inner corner
22+
# Нижний правый внутренний угол
2323

24-
In our case we need to substract the border size from the outer coordinates.
24+
В нашем случае нужно вычесть размеры рамки из внешних координат.
2525

26-
We could use CSS way:
26+
Это может быть сделано с помощью CSS:
2727

2828
```js
2929
let answer4 = [
@@ -32,7 +32,7 @@ let answer4 = [
3232
];
3333
```
3434

35-
An alternative way would be to add `clientWidth/clientHeight` to coordinates of the left-upper corner. That's probably even better:
35+
Другим вариантом решения было бы добавление `clientWidth/clientHeight` к координатам верхнего левого угла. Так даже было бы лучше.
3636

3737
```js
3838
let answer4 = [

2-ui/1-document/11-coordinates/1-find-point-coordinates/solution.view/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
<meta charset="utf-8">
66
<link rel="stylesheet" href="index.css">
77
<script>
8-
document.onclick = function(e) { // shows click coordinates
8+
document.onclick = function(e) { // показывает координаты точки клика
99
coords.innerHTML = e.clientX + ':' + e.clientY;
1010
};
1111
</script>
1212
</head>
1313

1414
<body>
1515

16-
Click anywhere to get window coordinates.
17-
<br> That's for testing, to check the result you get by JavaScript.
16+
Кликните в любом месте для получения координат в контексте окна.
17+
<br> Это для тестирования, чтобы проверить результат, который вы получили с помощью JavaScript.
1818
<br>
19-
<div id="coords">(click coordinates show up here)</div>
19+
<div id="coords">(координаты покажутся здесь)</div>
2020

2121

2222
<div id="field">

2-ui/1-document/11-coordinates/1-find-point-coordinates/source.view/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
<meta charset="utf-8">
66
<link rel="stylesheet" href="index.css">
77
<script>
8-
document.onclick = function(e) { // shows click coordinates
8+
document.onclick = function(e) { // показывает координаты точки клика
99
coords.innerHTML = e.clientX + ':' + e.clientY;
1010
};
1111
</script>
1212
</head>
1313

1414
<body>
1515

16-
Click anywhere to get window coordinates.
17-
<br> That's for testing, to check the result you get by JavaScript.
16+
Кликните в любом месте для получения координат в контексте окна.
17+
<br> Это для тестирования, чтобы проверить результат, который вы получили с помощью JavaScript.
1818
<br>
19-
<div id="coords">(click coordinates show up here)</div>
19+
<div id="coords">(координаты покажутся здесь)</div>
2020

2121

2222
<div id="field">
@@ -32,7 +32,7 @@
3232

3333

3434
<script>
35-
// ...your code...
35+
// ...ваш код...
3636
</script>
3737

3838
</body>

2-ui/1-document/11-coordinates/1-find-point-coordinates/task.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ importance: 5
22

33
---
44

5-
# Find window coordinates of the field
5+
# Найдите координаты точек относительно окна браузера
66

7-
In the iframe below you can see a document with the green "field".
7+
В ифрейме ниже располагается документ с зелёным "полем".
88

9-
Use JavaScript to find window coordinates of corners pointed by with arrows.
9+
Используйте JavaScript, чтобы найти координаты углов, обозначенных стрелками.
1010

11-
There's a small feature implemented in the document for convenience. A click at any place shows coordinates there.
11+
В документе уже реализован функционал, когда при клике на любом месте показываются соответствующие координаты.
1212

1313
[iframe border=1 height=360 src="source" link edit]
1414

15-
Your code should use DOM to get window coordinates of:
15+
Ваш код должен при помощи DOM получить четыре пары координат:
1616

17-
1. Upper-left, outer corner (that's simple).
18-
2. Bottom-right, outer corner (simple too).
19-
3. Upper-left, inner corner (a bit harder).
20-
4. Bottom-right, inner corner (there are several ways, choose one).
17+
1. верхний левый, внешний угол (это просто).
18+
2. нижний правый, внешний угол (тоже просто).
19+
3. верхний левый, внутренний угол (чуть сложнее).
20+
4. нижний правый, внутренний угол (есть несколько способов, выберите один).
2121

22-
The coordinates that you calculate should be the same as those returned by the mouse click.
22+
Координаты, вычисленные вами, должны совпадать с теми, которые возвращаются по клику мыши.
2323

24-
P.S. The code should also work if the element has another size or border, not bound to any fixed values.
24+
P.S. Код должен работать, если у элемента другие размеры или есть рамка, без привязки к конкретным числам.

2-ui/1-document/11-coordinates/head.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
let elem = document.getElementById('coords-show-mark');
55

6-
// no elem in ebook mode
6+
// в режиме чтения elem не существует
77
if (elem) {
88
elem.onclick = function() {
99

0 commit comments

Comments
 (0)