Prevent page jumping when clicking buttons
This commit is contained in:
parent
97d1536adb
commit
bfbbda2624
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "minesweeper",
|
"name": "minesweeper",
|
||||||
"version": "0.85.2",
|
"version": "0.85.3",
|
||||||
"description": "Just Minesweeper!",
|
"description": "Just Minesweeper!",
|
||||||
"author": "Florine W. Dekker",
|
"author": "Florine W. Dekker",
|
||||||
"browser": "dist/bundle.js",
|
"browser": "dist/bundle.js",
|
||||||
|
|
|
@ -107,6 +107,7 @@ export class Game {
|
||||||
+this.minesInput.value,
|
+this.minesInput.value,
|
||||||
this.solvableInput.checked
|
this.solvableInput.checked
|
||||||
);
|
);
|
||||||
|
this.customDifficultyOverlay.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -120,12 +121,22 @@ export class Game {
|
||||||
// New game form
|
// New game form
|
||||||
$("#new-game").addEventListener(
|
$("#new-game").addEventListener(
|
||||||
"click",
|
"click",
|
||||||
() =>
|
(event: MouseEvent) => {
|
||||||
this.initNewField(this.field?.width, this.field?.height, this.field?.mineCount, this.field?.isSolvable)
|
event.preventDefault();
|
||||||
|
|
||||||
|
this.initNewField(this.field?.width, this.field?.height, this.field?.mineCount, this.field?.isSolvable);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Restart
|
// Restart
|
||||||
$("#restart").addEventListener("click", () => this.field?.undo()); // Undoes all
|
$("#restart").addEventListener(
|
||||||
|
"click",
|
||||||
|
(event: MouseEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
this.field?.undo(); // Undoes all
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Seed
|
// Seed
|
||||||
const seedInput = $("#seed");
|
const seedInput = $("#seed");
|
||||||
|
@ -150,17 +161,33 @@ export class Game {
|
||||||
|
|
||||||
// Undo
|
// Undo
|
||||||
this.undo = $("#undo");
|
this.undo = $("#undo");
|
||||||
this.undo.addEventListener("click", () => this.field?.undo(1));
|
this.undo.addEventListener(
|
||||||
|
"click",
|
||||||
|
(event: MouseEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
return this.field?.undo(1);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Redo
|
// Redo
|
||||||
this.redo = $("#redo");
|
this.redo = $("#redo");
|
||||||
this.redo.addEventListener("click", () => this.field?.redo(1));
|
this.redo.addEventListener(
|
||||||
|
"click",
|
||||||
|
(event: MouseEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
return this.field?.redo(1);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Hint
|
// Hint
|
||||||
this.hint = $("#hint");
|
this.hint = $("#hint");
|
||||||
this.hint.addEventListener(
|
this.hint.addEventListener(
|
||||||
"click",
|
"click",
|
||||||
() => {
|
(event: MouseEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
if (this.field != null) {
|
if (this.field != null) {
|
||||||
this.statistics.hintsRequested++;
|
this.statistics.hintsRequested++;
|
||||||
this.display.hintSquare = Solver.getHint(this.field);
|
this.display.hintSquare = Solver.getHint(this.field);
|
||||||
|
@ -172,7 +199,9 @@ export class Game {
|
||||||
this.solve = $("#solve");
|
this.solve = $("#solve");
|
||||||
this.solve.addEventListener(
|
this.solve.addEventListener(
|
||||||
"click",
|
"click",
|
||||||
() => {
|
(event: MouseEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
if (this.field != null) {
|
if (this.field != null) {
|
||||||
this.statistics.solverUsages++;
|
this.statistics.solverUsages++;
|
||||||
Solver.solve(this.field);
|
Solver.solve(this.field);
|
||||||
|
|
Loading…
Reference in New Issue