Skip to content

Commit 04bf44b

Browse files
authored
Fix animation (#3)
Fixes #1
1 parent 608b038 commit 04bf44b

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

apps/wordle/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"type": "module",
44
"private": true,
55
"scripts": {
6-
"build": "bunx astro build",
7-
"deploy": "bunx wrangler deploy",
8-
"dev": "bunx astro dev",
6+
"build": "astro build",
7+
"deploy": "wrangler deploy",
8+
"dev": "astro dev",
99
"test": "bun test"
1010
},
1111
"dependencies": {

apps/wordle/src/hooks/useGame.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
import { createSignal, batch } from "solid-js";
2-
1+
import { batch, createSignal } from "solid-js";
2+
import { CONFIG, WORDS } from "~/config";
3+
import { getNewWord } from "~/lib/get-new-word";
4+
import { getTileColors } from "~/lib/get-tile-colors";
5+
import { showNotification } from "~/lib/show-notification";
6+
import { showSharePopup } from "~/lib/show-share-popup";
37
import type {
8+
BoardAction,
49
CurrentSection,
510
GameMode,
611
KeyColor,
7-
TileColor,
8-
BoardAction,
912
State,
13+
TileColor,
1014
} from "~/types";
1115

12-
import { WORDS, CONFIG } from "~/config";
13-
14-
import { getNewWord } from "~/lib/get-new-word";
15-
import { getTileColors } from "~/lib/get-tile-colors";
16-
import { showNotification } from "~/lib/show-notification";
17-
import { showSharePopup } from "~/lib/show-share-popup";
18-
1916
import { useSettings } from "./useSettings";
2017
import { useStats } from "./useStats";
2118
import { useTiles } from "./useTiles";
@@ -102,9 +99,9 @@ export function useGame() {
10299
setKeycolors((prev) => ({ ...prev, ...newKeyColors }));
103100
}
104101

105-
function submitGuess(guess: string) {
102+
async function submitGuess(guess: string) {
106103
if (!WORDS.guesses.includes(guess)) {
107-
shakeCurrentRow();
104+
await shakeCurrentRow();
108105
showNotification(`Word ${guess.toUpperCase()} does not exist`);
109106
return;
110107
}

apps/wordle/src/hooks/useTiles.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ export function useTiles() {
6868
}, 150);
6969
}
7070

71-
function shakeCurrentRow() {
71+
async function shakeCurrentRow() {
7272
const row = getCurrentRow();
7373
const start = row * CONFIG.wordLength;
7474
const end = start + CONFIG.wordLength;
7575

76+
// Wait for any ongoing pop animations to finish (150ms)
77+
await delay(150);
78+
7679
setTiles((prev) => {
7780
const copy = [...prev];
7881
for (let i = start; i < end; i++) {

0 commit comments

Comments
 (0)