Skip to content

Commit

Permalink
fixed reveal animation playing on first render
Browse files Browse the repository at this point in the history
  • Loading branch information
LooLzzz committed Aug 31, 2024
1 parent 5e43d80 commit 6d9a6a6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/WordsGuesser/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const WordsGuesser = () => {
const isXs = useMediaQuery('(max-width: 400px)')
const [selectedIdx, setSelectedIdx] = useState<number | undefined>(undefined)
const [shake, setShake] = useState(false)
const [isFirstGuessInSession, setIsFirstGuessInSession] = useState(true)

const activeGuessIdx = guesses.length
const lastGuess = guesses.at(-1)
Expand Down Expand Up @@ -63,6 +64,7 @@ const WordsGuesser = () => {
case 'Enter':
if (numberOfEmptyLetters === 0) {
if (isGuessInWordsSet && !isAlreadyGuess) {
setIsFirstGuessInSession(false)
submitCurrentGuess()
} else {
setShake(true)
Expand Down Expand Up @@ -186,7 +188,7 @@ const WordsGuesser = () => {
guessedLetters={isActive ? currentGuess : guesses[idx]?.split('')}
selectedIdx={isActive ? selectedIdx : undefined}
onSelectIdx={isActive ? handleSelectIdx : undefined}
revealAnimation={idx === activeGuessIdx - 1}
revealAnimation={!isFirstGuessInSession && idx === activeGuessIdx - 1}
/>
</Box>
)
Expand Down
1 change: 0 additions & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const theme = createTheme({
createRoot(document.getElementById('root')!).render(
<StrictMode>
<MantineProvider
defaultColorScheme='dark'
colorSchemeManager={colorSchemeManager}
cssVariablesResolver={cssResolver}
theme={theme}
Expand Down

0 comments on commit 6d9a6a6

Please sign in to comment.