Skip to content

Commit f27265a

Browse files
committed
Update 2-ui\1-document\11-coordinates\article.md
1 parent 02b01dd commit f27265a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Il metodo `elem.getBoundingClientRect()` restituisce le coordinate relative alla
2626
Ecco le principali proprietà di `DOMRect`:
2727

2828
- `x/y` -- le coordinate X/Y dell'origine rettangolo relative alla finestra,
29-
- `width/height` -- larghezza/altezza del rettangolo (può avere valori negativi).
29+
- `width/height` -- larghezza/altezza del rettangolo (possono avere valori negativi).
3030

3131
Ci sono, inoltre, proprietà derivate:
3232

@@ -56,23 +56,23 @@ right:${r.right}
5656
Se scorrete la pagina e ripetete il test, noterete che quando cambia la posizione relativa alla finestra del pulsante, cambiano anche le sue coordinate relative alla finestra (`y/top/bottom` se scorri verticalmente)
5757
```
5858

59-
Here's the picture of `elem.getBoundingClientRect()` output:
59+
Di seguito un'immagine descrittiva dell'output di `elem.getBoundingClientRect()`:
6060

6161
![](coordinates.svg)
6262

63-
As you can see, `x/y` and `width/height` fully describe the rectangle. Derived properties can be easily calculated from them:
63+
Come potete osservare, `x/y` e `width/height` descrivono pienamente il rettangolo. A partire da queste si possono calcolare agevolmente le proprietà derivate:
6464

6565
- `left = x`
6666
- `top = y`
6767
- `right = x + width`
6868
- `bottom = y + height`
6969

70-
Please note:
70+
Nota bene:
7171

72-
- Coordinates may be decimal fractions, such as `10.5`. That's normal, internally browser uses fractions in calculations. We don't have to round them when setting to `style.left/top`.
73-
- Coordinates may be negative. For instance, if the page is scrolled so that `elem` is now above the window, then `elem.getBoundingClientRect().top` is negative.
72+
- Le coordinate possono avere valori decimali, come `10.5`. È normale, il browser internamente usa frazioni nei calcoli. Non dobbiamo arrotondare quando assegniamo i valori a `style.left/top`.
73+
- Le coordinate possono essere negative. Per esempio se la pagina scorre in modo che `elem` sia al di là del bordo della dinestra, allora `elem.getBoundingClientRect().top` è negativa.
7474

75-
```smart header="Why derived properties are needed? Why does `top/left` exist if there's `x/y`?"
75+
```smart header="Perché le proprietà derivate sono necessarie? Perché `top/left` esistono se ci sono già `x/y`?"
7676
Mathematically, a rectangle is uniquely defined with its starting point `(x,y)` and the direction vector `(width,height)`. So the additional derived properties are for convenience.
7777

7878
Technically it's possible for `width/height` to be negative, that allows for "directed" rectangle, e.g. to represent mouse selection with properly marked start and end.

0 commit comments

Comments
 (0)