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
Copy file name to clipboardExpand all lines: 2-ui/1-document/11-coordinates/article.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ Il metodo `elem.getBoundingClientRect()` restituisce le coordinate relative alla
26
26
Ecco le principali proprietà di `DOMRect`:
27
27
28
28
-`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).
30
30
31
31
Ci sono, inoltre, proprietà derivate:
32
32
@@ -56,23 +56,23 @@ right:${r.right}
56
56
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)
57
57
```
58
58
59
-
Here's the picture of`elem.getBoundingClientRect()` output:
59
+
Di seguito un'immagine descrittiva dell'output di`elem.getBoundingClientRect()`:
60
60
61
61

62
62
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:
64
64
65
65
-`left = x`
66
66
-`top = y`
67
67
-`right = x + width`
68
68
-`bottom = y + height`
69
69
70
-
Please note:
70
+
Nota bene:
71
71
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.
74
74
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`?"
76
76
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.
77
77
78
78
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