Skip to content

Commit 4818259

Browse files
committed
Merge branch 'master' of https://github.com/javascript-tutorial/it.javascript.info into article/10-if-else
2 parents b4e8baa + 8a618de commit 4818259

File tree

17 files changed

+164
-165
lines changed

17 files changed

+164
-165
lines changed

1-js/02-first-steps/13-while-for/1-loop-last-value/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ while (i) {
88
}
99
```
1010

11-
Ogni iterazione del ciclo decrementa `i` di `1`. Il controllo `while(i)` interrompe il ciclo quando `i == 0`.
11+
Ogni iterazione del ciclo decrementa `i` di `1`. Il controllo `while(i)` interrompe il ciclo quando `i = 0`.
1212

1313
Quindi, gli step del ciclo sono ("loop unrolled"):
1414

1-js/02-first-steps/13-while-for/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ label: for (...)
373373
La chiamata a `break/continue` è possibile solo dall'interno di un ciclo, e l'etichetta deve essere da qualche parte **sopra** la chiamata.
374374
````
375375

376-
## Sommario
376+
## Riepilogo
377377

378378
Abbiamo visto tre tipi di cicli:
379379

1-js/04-object-basics/07-optional-chaining/article.md

Lines changed: 78 additions & 78 deletions
Large diffs are not rendered by default.

2-ui/2-events/01-introduction-browser-events/01-hide-other/task.md

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

33
---
44

5-
# Hide on click
5+
# Nascondere al click
66

7-
Add JavaScript to the `button` to make `<div id="text">` disappear when we click it.
7+
Aggiungi del codice JavaScript al pulsante `button` per nascondere `<div id="text">` al click.
88

9-
The demo:
9+
Demo:
1010

1111
[iframe border=1 src="solution" height=80]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Can use `this` in the handler to reference "the element itself" here:
1+
Qui possiamo usare `this` nel gestore per fare riferimento all'"elemento stesso":
22

33
```html run height=50
4-
<input type="button" onclick="this.hidden=true" value="Click to hide">
4+
<input type="button" onclick="this.hidden=true" value="Clicca per nascondere">
55
```

2-ui/2-events/01-introduction-browser-events/02-hide-self-onclick/task.md

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

33
---
44

5-
# Hide self
5+
# Nascondere sé stesso
66

7-
Create a button that hides itself on click.
7+
Creare un pulsante che nasconde sé stesso al click.
88

99
```online
10-
Like this:
11-
<input type="button" onclick="this.hidden=true" value="Click to hide">
10+
Come questo:
11+
<input type="button" onclick="this.hidden=true" value="Clicca per nascondere">
1212
```
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
The answer: `1` and `2`.
1+
Risposta: `1` e `2`.
22

3-
The first handler triggers, because it's not removed by `removeEventListener`. To remove the handler we need to pass exactly the function that was assigned. And in the code a new function is passed, that looks the same, but is still another function.
3+
Il primo gestore verrà innescato, poiché non viene rimosso da `removeEventListener`. Per rimuovere il gestore dobbiamo passare esattamente la stessa funzione che era stata assegnata. E nel codice viene passata una nuova funzione, che è identica, ma è comunque una nuova funzione.
44

5-
To remove a function object, we need to store a reference to it, like this:
5+
Per poter rimuovere un oggetto funzione, dobbiamo salvarci un suo riferimento:
66

77
```js
88
function handler() {
@@ -13,4 +13,4 @@ button.addEventListener("click", handler);
1313
button.removeEventListener("click", handler);
1414
```
1515

16-
The handler `button.onclick` works independently and in addition to `addEventListener`.
16+
Il gestore `button.onclick` aggiunto ad `addEventListener` funziona perfettamente.

2-ui/2-events/01-introduction-browser-events/03-which-handlers-run/task.md

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

33
---
44

5-
# Which handlers run?
5+
# Quale gestore verrà eseguito?
66

7-
There's a button in the variable. There are no handlers on it.
7+
Nella variabile c'è un pulsante. Non vi sono gestori assegnati.
88

9-
Which handlers run on click after the following code? Which alerts show up?
9+
Dopo aver eseguito questo codice, quali gestori verranno eseguiti al click sul pulsante? Quale alert verrà mostrato?
1010

1111
```js no-beautify
1212
button.addEventListener("click", () => alert("1"));
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

2-
First we need to choose a method of positioning the ball.
2+
Per prima cosa dobbiamo scegliere un metodo per posizionare la palla.
33

4-
We can't use `position:fixed` for it, because scrolling the page would move the ball from the field.
4+
Non possiamo usare `position:fixed` per questo, perché lo scorrimento della pagina sposterebbe la palla dal campo.
55

6-
So we should use `position:absolute` and, to make the positioning really solid, make `field` itself positioned.
6+
Dobbiamo quindi usare `position:absolute` per la palla, e per rendere il posizionamento stabile, posizionare anche `field` stesso ("static" se non diversamente specificato).
77

8-
Then the ball will be positioned relatively to the field:
8+
In questo modo a palla verrà posizionata in relazione al campo:
99

1010
```css
1111
#field {
@@ -16,36 +16,36 @@ Then the ball will be positioned relatively to the field:
1616

1717
#ball {
1818
position: absolute;
19-
left: 0; /* relative to the closest positioned ancestor (field) */
19+
left: 0; /* relativo all'antenato più vicino (field) */
2020
top: 0;
21-
transition: 1s all; /* CSS animation for left/top makes the ball fly */
21+
transition: 1s all; /* Una animazione CSS impostata su left/top fa volare la palla */
2222
}
2323
```
2424

25-
Next we need to assign the correct `ball.style.left/top`. They contain field-relative coordinates now.
25+
Il prossimo passo sarà quello di assegnare correttamente `ball.style.left/top`, le cui coordinate saranno relazionate alla dimensione del campo.
2626

27-
Here's the picture:
27+
Osserviamo la figura:
2828

2929
![](move-ball-coords.svg)
3030

31-
We have `event.clientX/clientY` -- window-relative coordinates of the click.
31+
`event.clientX/clientY` sono le coordinate del click relative alla window (N.d.T. l'oggetto window).
3232

33-
To get field-relative `left` coordinate of the click, we can substract the field left edge and the border width:
33+
Per ottenere le coordinate `left` relative al campo, dobbiamo sottrarre il valore del limite sinistro del campo e la sua larghezza:
3434

3535
```js
3636
let left = event.clientX - fieldCoords.left - field.clientLeft;
3737
```
3838

39-
Normally, `ball.style.left` means the "left edge of the element" (the ball). So if we assign that `left`, then the ball edge, not center, would be under the mouse cursor.
39+
Normalmente, `ball.style.left` significa "limite destro dell'elemento" (la palla). Ma se assegnassimo questo valore di `left`, sotto il puntatore si verrebbe a posizionare, appunto, il limite destro della palla, e non il suo centro.
4040

41-
We need to move the ball half-width left and half-height up to make it center.
41+
Per poter centrare la palla, dobbiamo spostarla tenendo conto della metà della sua altezza e metà della sua larghezza.
4242

43-
So the final `left` would be:
43+
Quindi il `left` definitivo sarebbe:
4444

4545
```js
4646
let left = event.clientX - fieldCoords.left - field.clientLeft - ball.offsetWidth/2;
4747
```
4848

49-
The vertical coordinate is calculated using the same logic.
49+
Le coordinate in verticale vengono calcolate usando la stessa logica.
5050

51-
Please note that the ball width/height must be known at the time we access `ball.offsetWidth`. Should be specified in HTML or CSS.
51+
Nota bene che larghezza e altezza della palla devono essere note nel momento in cui accediamo a `ball.offsetWidth`. Dovrebbero essere specificate nell'HTML o nel CSS.

2-ui/2-events/01-introduction-browser-events/04-move-ball-field/task.md

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

33
---
44

5-
# Move the ball across the field
5+
# Sposta la palla sul campo
66

7-
Move the ball across the field to a click. Like this:
7+
Sposta la palla sul campo al click. Così:
88

99
[iframe src="solution" height="260" link]
1010

11-
Requirements:
11+
Requisiti:
1212

13-
- The ball center should come exactly under the pointer on click (if possible without crossing the field edge).
14-
- CSS-animation is welcome.
15-
- The ball must not cross field boundaries.
16-
- When the page is scrolled, nothing should break.
13+
- Il centro della palla, al click, dovrà essere esattamente sotto il puntatore (possibilmente senza attraversare i bordi del campo).
14+
- Le animazioni CSS sono ben accette.
15+
- La palla non deve attraversare i confini del campo.
16+
- Allo scroll della pagina, lo script non si deve rompere.
1717

18-
Notes:
18+
Note:
1919

20-
- The code should also work with different ball and field sizes, not be bound to any fixed values.
21-
- Use properties `event.clientX/event.clientY` for click coordinates.
20+
- Il codice dovrebbe funzionare anche con differenti tipi di palle e campi, senza essere legato a nessun valore prefissato.
21+
- Usa le proprietà `event.clientX/event.clientY` per le coordinate del click.

0 commit comments

Comments
 (0)