Skip to content

Commit

Permalink
feat: Add function to reset grid to initial state
Browse files Browse the repository at this point in the history
  • Loading branch information
SverreNystad committed Aug 10, 2024
1 parent d8a0b61 commit 843e17e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions frontend/src/services/animationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,18 @@ const animatePath = (path: Node[]) => {
timeoutIds.push(timeoutId); // Store timeout ID
});
};

/**
* Reset the grid to its initial state by clearing any previous animations and resetting the tiles
*/
export const resetGrid = () => {
clearPreviousAnimations();
tiles.value = tiles.value.map((tile) => {
return {
...tile,
isExplored: false,
isPath: false,
weight: 0,
};
});
};

0 comments on commit 843e17e

Please sign in to comment.