Skip to content

Commit 1145ea8

Browse files
committed
Update 2-ui\1-document\11-coordinates
1 parent bef0280 commit 1145ea8

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+
# Angoli esterni
22

3-
Outer corners are basically what we get from [elem.getBoundingClientRect()](https://developer.mozilla.org/en-US/docs/DOM/element.getBoundingClientRect).
3+
Gli angoli esterni sono fondamentalmente quello che otteniamo da [elem.getBoundingClientRect()](https://developer.mozilla.org/en-US/docs/DOM/element.getBoundingClientRect).
44

5-
Coordinates of the upper-left corner `answer1` and the bottom-right corner `answer2`:
5+
Le coordinate dell'angolo superiore sinistro `answer1` e quelle dell'angolo inferiore destro `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+
# Angolo interno superiore sinistro
1515

16-
That differs from the outer corner by the border width. A reliable way to get the distance is `clientLeft/clientTop`:
16+
Questo differisce dall'angolo esterno solo per la larghezza del bordo. Un modo affidabile per calcolare la distanza è `clientLeft/clientTop`:
1717

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

22-
# Right-bottom inner corner
22+
# Angolo interno inferiore destro
2323

24-
In our case we need to substract the border size from the outer coordinates.
24+
Nel nostro caso possiamo sottrarre la misura del bordo dalle coordinate esterne.
2525

26-
We could use CSS way:
26+
Potremmo utilizzare il valore 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+
Un'alternativa sarebbe aggiungere `clientWidth/clientHeight` alle coordinate dell'angolo interno superiore sinistro. Questa è probabilmente la soluzione migliore:
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) { // mostra le coordinate del clic
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+
Clicca in un punto qualsiasi per ottenere le coordinate relative alla finestra.
17+
<br> Fatelo a scopo di test, per verificare il risultato che ottenete con JavaScript.
1818
<br>
19-
<div id="coords">(click coordinates show up here)</div>
19+
<div id="coords">(le coordinate del clic vengono mostrate qui)</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) { // mostra le coordinate del clic
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+
Clicca in un punto qualsiasi per ottenere le coordinate relative alla finestra.
17+
<br> Fatelo a scopo di test, per verificare il risultato che ottenete con JavaScript.
1818
<br>
19-
<div id="coords">(click coordinates show up here)</div>
19+
<div id="coords">(le coordinate del clic vengono mostrate qui)</div>
2020

2121

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

3333

3434
<script>
35-
// ...your code...
35+
// ...il tuo codice...
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+
# Trovate le coordinate del campo relative alla finestra
66

7-
In the iframe below you can see a document with the green "field".
7+
Nell'iframe sotto potete osservare un documento con un "campo" verde.
88

9-
Use JavaScript to find window coordinates of corners pointed by with arrows.
9+
Usate JavaScript per trovare le coordinate relative alla finestra degli angoli indicati dalle frecce.
1010

11-
There's a small feature implemented in the document for convenience. A click at any place shows coordinates there.
11+
Per comodità è stata implementata una semplice funzionalità nel documento: un click in un punto qualsiasi ne mostra le coordinate.
1212

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

15-
Your code should use DOM to get window coordinates of:
15+
Il vostro codice dovrebbe usare il DOM per ottenere le coordinate relative alla finestra di:
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. angolo esterno superiore sinistro (è semplice).
18+
2. angolo esterno inferiore destro (semplice anche questo).
19+
3. angolo interno superiore sinistro (un po' più difficile).
20+
4. angolo interno inferiore destro (esistono vari modi, sceglietene uno).
2121

22-
The coordinates that you calculate should be the same as those returned by the mouse click.
22+
Le coordinate che calcolate dovrebbero essere le stesse di quelle mostrate al click del mouse.
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. Il codice dovrebbe funzionare anche se l'elemento ha un'altra dimensione o un altro bordo, non deve dipendere da valori fissi.

2-ui/1-document/11-coordinates/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ let elem = document.getElementById("coords-show-mark");
156156
function createMessageUnder(elem, html) {
157157
// crea l'elemento messaggio
158158
let message = document.createElement('div');
159-
// è preferibile usare una classe CSS per assegnargli degli stili
159+
// per assegnare degli stili è preferibile usare una classe CSS
160160
message.style.cssText = "position:fixed; color: red";
161161
162162
*!*

0 commit comments

Comments
 (0)