Skip to content

Commit 7413592

Browse files
committed
Update 2-ui\1-document\09-size-and-scroll\tasks
1 parent 516abff commit 7413592

File tree

4 files changed

+23
-24
lines changed

4 files changed

+23
-24
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
The solution is:
1+
La soluzione è:
22

33
```js
44
let scrollBottom = elem.scrollHeight - elem.scrollTop - elem.clientHeight;
55
```
66

7-
In other words: (full height) minus (scrolled out top part) minus (visible part) -- that's exactly the scrolled out bottom part.
7+
In altre parole: (altezza totale) meno (misura dello scorrimento dall'alto) meno (altezza dell'area di scorrimento visibile). Il risultato è esattamente la misura della parte inferiore che resta da scorrere.

2-ui/1-document/09-size-and-scroll/1-get-scroll-height-bottom/task.md

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

33
---
44

5-
# What's the scroll from the bottom?
5+
# Qual è la misura dello scorrimento verso il basso?
66

7-
The `elem.scrollTop` property is the size of the scrolled out part from the top. How to get the size of the bottom scroll (let's call it `scrollBottom`)?
7+
La proprietà `elem.scrollTop` è la misura della parte superiore di un elemento fuori dall'area visibile di scorrimento. Come ottenere la misura della parte inferiore (chiamiamola `scrollBottom`)?
88

9-
Write the code that works for an arbitrary `elem`.
9+
Scrivete il codice che funzioni per un elemento arbitrario `elem`.
1010

11-
P.S. Please check your code: if there's no scroll or the element is fully scrolled down, then it should return `0`.
11+
P.S. Verificate il vostro codice: se non c'è scorrimento o è stato effettuato tutto lo scorrimento verso il basso, allora dovrebbe restituire `0`.

2-ui/1-document/09-size-and-scroll/article.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,22 @@ Impostare `scrollTop` a `0` o su un grande valore, come `1e9`, farà sì che l'e
216216
217217
## Non ricavare la larghezza o l'altezza dai CSS
218218
219-
We've just covered geometry properties of DOM elements, that can be used to get widths, heights and calculate distances.
219+
Abbiamo appena trattato le proprietà geometriche degli elementi DOM che usiamo per ricavare larghezza, altezza e per calcolare le distanze.
220220
221-
But as we know from the chapter <info:styles-and-classes>, we can read CSS-height and width using `getComputedStyle`.
221+
Ma come abbiamo imparato dal capitolo <info:styles-and-classes>, possiamo ottenere la larghezza e l'altezza CSS tramite `getComputedStyle`.
222222
223-
So why not to read the width of an element with `getComputedStyle`, like this?
223+
Dunque, perché non leggere la larghezza di un elemento con `getComputedStyle` in questo modo?
224224
225225
```js run
226226
let elem = document.body;
227227
228-
alert( getComputedStyle(elem).width ); // show CSS width for elem
228+
alert( getComputedStyle(elem).width ); // mostra la larghezza CSS per elem
229229
```
230230
231-
Why should we use geometry properties instead? There are two reasons:
231+
Perché invece dovremmo usare le proprietà geometriche? Ci sono due ragioni:
232232
233-
1. First, CSS `width/height` depend on another property: `box-sizing` that defines "what is" CSS width and height. A change in `box-sizing` for CSS purposes may break such JavaScript.
234-
2. Second, CSS `width/height` may be `auto`, for instance for an inline element:
233+
1. La prima, le proprietà CSS `width/height` dipendono da un'altra proprietà: `box-sizing` che definisce "cosa siano" la larghezza e l'altezza CSS. Una modifica in `box-sizing` per scopi riguardanti i CSS possono rompere un JavaScript che fa affidamento su questa.
234+
2. La seconda, le proprietà CSS `width/height` possono valere `auto`, per esempio per un elemento inline:
235235
236236
```html run
237237
<span id="elem">Hello!</span>
@@ -243,23 +243,22 @@ Why should we use geometry properties instead? There are two reasons:
243243
</script>
244244
```
245245
246-
From the CSS standpoint, `width:auto` is perfectly normal, but in JavaScript we need an exact size in `px` that we can use in calculations. So here CSS width is useless.
246+
Dal punto di vista dei CSS, `width:auto` è perfettamente normale, ma in JavaScript abbiamo bisogno di un'esatta dimensione in `px` da usare nei calcoli. In questo caso, quindi, la larghezza CSS è inutile.
247247
248-
And there's one more reason: a scrollbar. Sometimes the code that works fine without a scrollbar becomes buggy with it, because a scrollbar takes the space from the content in some browsers. So the real width available for the content is *less* than CSS width. And `clientWidth/clientHeight` take that into account.
248+
Ma c'è un'altra ragione: la barra di scorrimento. Talvolta un codice che funziona bene senza barra di scorrimento, con questa diventa difettoso, perché la barra di scorrimento su alcuni browser ricava il suo spazio dall'area del contenuto. La larghezza effettiva per il contenuto, dunque, è *minore* della larghezza CSS e `clientWidth/clientHeight` ne tengono conto.
249249
250-
...But with `getComputedStyle(elem).width` the situation is different. Some browsers (e.g. Chrome) return the real inner width, minus the scrollbar, and some of them (e.g. Firefox) -- CSS width (ignore the scrollbar). Such cross-browser differences is the reason not to use `getComputedStyle`, but rather rely on geometry properties.
250+
...Ma con `getComputedStyle(elem).width` la situazione è differente. Alcuni browser (es. Chrome) restituiscono la larghezza interna effettiva, meno la barra di scorrimento, mentre altri (es. Firefox) la larghezza CSS (ignorando la barra di scorrimento). Queste diversità cross-browser costituiscono il motivo per il quale non usare `getComputedStyle` ma piuttosto fare affidamento sulle proprietà geometriche.
251251
252252
```online
253-
If your browser reserves the space for a scrollbar (most browsers for Windows do), then you can test it below.
253+
Se il tuo browser ricava lo spazio per la barra di scorrimento dall'area del contenuto (la maggior parte dei browser per Windows lo fa), allora puoi testarlo qui di seguito.
254254
255255
[iframe src="cssWidthScroll" link border=1]
256256
257-
The element with text has CSS `width:300px`.
257+
L'elemento con il testo ha una dichiarazione CSS `width:300px`.
258258
259-
On a Desktop Windows OS, Firefox, Chrome, Edge all reserve the space for the scrollbar. But Firefox shows `300px`, while Chrome and Edge show less. That's because Firefox returns the CSS width and other browsers return the "real" width.
259+
Sul sistema operativo Windows i browser Firefox, Chrome, Edge ricavano lo spazio per la barra di scorrimento allo stesso modo. Ma Firefox mostra `300px`, mentre Chrome e Edge mostrano un valore minore. Questo perché Firefox restituisce la larghezza CSS e gli altri browser restituiscono la larghezza "reale".
260260
```
261-
262-
Please note that the described difference is only about reading `getComputedStyle(...).width` from JavaScript, visually everything is correct.
261+
Si noti che la discrepanza descritta riguarda solo la lettura di `getComputedStyle(...).width` tramite JavaScript, dal punto di vista visuale non ci sono differenze.
263262
264263
## Riepilogo
265264
@@ -273,4 +272,4 @@ Gli elementi hanno le seguenti proprietà geometriche:
273272
- `scrollWidth/scrollHeight` -- la larghezza/altezza del contenuto, proprio come `clientWidth/clientHeight`, ma comprende anche la parte di un elemento nascosta e fuori dall'area visibile di scorrimento.
274273
- `scrollLeft/scrollTop` -- la larghezza/altezza della parte superiore di un elemento fuori dall'area visibile di scorrimento, partendo dal suo angolo in alto a sinistra.
275274
276-
Tutte le proprietà sono in sola lettura tranne `scrollLeft/scrollTop` che che fanno scorrere l'elemento nel browser se modificate.
275+
Tutte le proprietà sono in sola lettura tranne `scrollLeft/scrollTop` che, se modificate, fanno scorrere l'elemento nel browser.

2-ui/1-document/09-size-and-scroll/metric.view/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ <h3>Introduction</h3>
4343
</div>
4444

4545

46-
<div id="mouse-wrap">Mouse coordinates: <span id="mouse">...</span></div>
46+
<div id="mouse-wrap">Coordinate del mouse: <span id="mouse">...</span></div>
4747
<div id="info"></div>
4848

4949

@@ -54,7 +54,7 @@ <h3>Introduction</h3>
5454
offsetParent: ['offsetParent', 'offsetLeft', 'offsetTop']
5555
};
5656

57-
info.innerHTML = '<h3>Click to see the value:</h3>';
57+
info.innerHTML = '<h3>Clicca per scoprire il valore:</h3>';
5858
for (let k in props) {
5959
info.innerHTML += `<h4>${k}</h4>`;
6060
let prop = props[k];

0 commit comments

Comments
 (0)