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/10-size-and-scroll-window/article.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,33 +76,33 @@ Queste proprietà sono in sola lettura.
76
76
## Lo scorrimento con scrollTo, scrollBy, scrollIntoView [#window-scroll]
77
77
78
78
```warn
79
-
To scroll the page with JavaScript, its DOM must be fully built.
79
+
Per scorrere la pagina con JavaScript, il DOM deve essere stato completamente elaborato.
80
80
81
-
For instance, if we try to scroll the page with a script in `<head>`, it won't work.
81
+
Se proviamo, ad esempio, a scorrere la pagina con uno script nella sezione `<head>`, non funzionerà.
82
82
```
83
83
84
-
Regular elements can be scrolled by changing `scrollTop/scrollLeft`.
84
+
I normali elementi possono essere fatti scorrere modificando `scrollTop/scrollLeft`.
85
85
86
-
We can do the same for the page using `document.documentElement.scrollTop/scrollLeft` (except Safari, where `document.body.scrollTop/Left` should be used instead).
86
+
Possiamo applicare lo stesso principio per la pagina usando `document.documentElement.scrollTop/scrollLeft` (tranne che per Safari, con il quale dovremmo usare invece `document.body.scrollTop/Left`).
87
87
88
-
Alternatively, there's a simpler, universal solution: special methods [window.scrollBy(x,y)](mdn:api/Window/scrollBy) and [window.scrollTo(pageX,pageY)](mdn:api/Window/scrollTo).
88
+
In alternativa, c'è una soluzione più semplice ed universale: i metodi speciali [window.scrollBy(x,y)](mdn:api/Window/scrollBy) e [window.scrollTo(pageX,pageY)](mdn:api/Window/scrollTo).
89
89
90
-
- The method `scrollBy(x,y)` scrolls the page *relative to its current position*. For instance, `scrollBy(0,10)` scrolls the page `10px` down.
90
+
- Il metodo `scrollBy(x,y)` scorre la pagina *in base alla sua posizione corrente*. Per esempio, `scrollBy(0,10)` scorre la pagina di `10px` in basso.
91
91
92
92
```online
93
-
The button below demonstrates this:
93
+
Il pulsante in basso dimostra quanto appena affermato:
- The method `scrollTo(pageX,pageY)` scrolls the page *to absolute coordinates*, so that the top-left corner of the visible part has coordinates `(pageX, pageY)` relative to the document's top-left corner. It's like setting `scrollLeft/scrollTop`.
97
+
- Il metodo `scrollTo(pageX,pageY)` scorre la pagina *in base alle coordinate assolute*, di modo che l'angolo superiore sinistro della parte visibile abbia le coordinate `(pageX, pageY)` relative all'angolo superiore sinistro del documento. Di fatto, è come agire sulle proprietà `scrollLeft/scrollTop`.
98
98
99
-
To scroll to the very beginning, we can use `scrollTo(0,0)`.
99
+
Per scorrere fino all'inizio possiamo usare `scrollTo(0,0)`.
Questi metodo godono di un supporto universale da parte di tutti i browser.
106
106
107
107
## scrollIntoView
108
108
@@ -145,7 +145,7 @@ The drawback of the method is that the scrollbar disappears. If it occupied some
145
145
146
146
That looks a bit odd, but can be worked around if we compare `clientWidth` before and after the freeze. If it increased (the scrollbar disappeared), then add `padding` to `document.body` in place of the scrollbar to keep the content width the same.
0 commit comments