Skip to content

Commit ffc0219

Browse files
Update main.js
1 parent 8721fce commit ffc0219

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

js/main.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
23
const ELIMINA = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="color: red;" fill="currentColor" class="bi bi-dash-lg" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M2 8a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11A.5.5 0 0 1 2 8Z"/></svg>'
34
const CREA = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" style="color: green;font-size:20px;" fill="currentColor" class="bi bi-plus-lg" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 2a.5.5 0 0 1 .5.5v5h5a.5.5 0 0 1 0 1h-5v5a.5.5 0 0 1-1 0v-5h-5a.5.5 0 0 1 0-1h5v-5A.5.5 0 0 1 8 2Z"/></svg> '
45
const MODIFICA = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil" viewBox="0 0 16 16"><path d="M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168l10-10zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207 11.207 2.5zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293l6.5-6.5zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325z"/></svg>'
@@ -1595,25 +1596,27 @@ output.addEventListener("mousedown", function(evento) {
15951596
const distanza = Math.sqrt(Math.pow((puntoRilascio.x - puntoPressione.x), 2) + Math.pow((puntoRilascio.y - puntoPressione.y), 2));
15961597

15971598
const sogliaVerticale = 50;
1599+
let newChoice = choice;
15981600
if (distanza >= 150 && percorsi && percorsi > 1 && choice >= 0 && choice < percorsi) {
15991601
if (Math.abs(puntoRilascio.y - puntoPressione.y) < sogliaVerticale) {
16001602
if (puntoRilascio.x > puntoPressione.x) {
16011603
spostamentoDestra = true;
16021604
if (choice == 0) {
1603-
choice = percorsi - 1;
1605+
newChoice = percorsi - 1;
16041606
} else {
1605-
choice--;
1607+
newChoice--;
16061608
}
16071609
} else if (puntoRilascio.x < puntoPressione.x) {
16081610
spostamentoDestra = false;
16091611
if (choice == percorsi - 1) {
1610-
choice = 0;
1612+
newChoice = 0;
16111613
} else {
1612-
choice++;
1614+
newChoice++;
16131615
}
16141616
}
16151617
}
1616-
document.getElementById("output").innerHTML = risultato();
1618+
changeChoice(newChoice)
1619+
16171620
}
16181621
});
16191622

@@ -1623,22 +1626,24 @@ output.addEventListener("mousedown", function(evento) {
16231626
const distanza = Math.sqrt(Math.pow((puntoRilascio.x - puntoPressione.x), 2) + Math.pow((puntoRilascio.y - puntoPressione.y), 2));
16241627

16251628
const sogliaVerticale = 50;
1629+
let newChoice = choice;
16261630
if (distanza >= 150 && percorsi > 1) {
16271631

16281632
if (Math.abs(puntoRilascio.y - puntoPressione.y) < sogliaVerticale) {
16291633
if (puntoRilascio.x > puntoPressione.x) {
16301634
spostamentoDestra = true;
1631-
if(choice == 0)choice = percorsi-1;
1632-
else choice--;
1635+
if(choice == 0)newChoice = percorsi-1;
1636+
else newChoice--;
16331637

16341638
} else if (puntoRilascio.x < puntoPressione.x) {
16351639
spostamentoDestra = false;
1636-
if(choice == percorsi-1)choice = 0;
1637-
else choice++;
1640+
if(choice == percorsi-1)newChoice = 0;
1641+
else newChoice++;
16381642
}
16391643
}
16401644

1641-
document.getElementById("output").innerHTML =risultato()
1645+
changeChoice(newChoice)
1646+
16421647

16431648
}
1644-
});
1649+
});

0 commit comments

Comments
 (0)