Skip to content

Commit

Permalink
πŸš‘ fix: remaining word drop issue
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmo1031 committed May 29, 2023
1 parent 0d3bca8 commit a259a84
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ recognition.onresult = (event) => {
let delay = 0;

words.forEach((word) => {
delay += Math.round(Math.random() * settings.WORD_CREATE_DELAY * 1000);
console.log(`Next drop word: ${word}, delay: ${delay}`);
if (isGameOver) {
return console.log('Game Already Over! skip...');
}
addTimeout(drop, word, delay);
delay += Math.round(Math.random() * settings.WORD_CREATE_DELAY * 1000);
});
};

Expand Down Expand Up @@ -113,19 +116,18 @@ const handleInput = (event) => {

// λͺ¨λ“  νƒ€μž„μ•„μ›ƒ 클리어
const clearAllTimeouts = () => {
console.log('clear timeouts');
timeouts.forEach((timeoutId) => clearTimeout(timeoutId));
timeouts.length = 0;
};

const handleAnimationEnd = () => {
const wordElements = Array.from(document.getElementsByClassName('word'));
clearAllTimeouts();
wordElements.forEach((element) => {
element.parentNode.removeChild(element);
});
if (document.getElementsByClassName('word').length === 0 && !isGameOver) {
isGameOver = true;
clearAllTimeouts();
gameOver();
}
};
Expand Down Expand Up @@ -250,7 +252,6 @@ const handleRadioHover = (event) => {
};

const handleSelection = (event) => {
console.log('call!');
if (
event.key === ' ' ||
event.key === 'Enter' ||
Expand Down Expand Up @@ -378,7 +379,6 @@ const adjustDropHeight = () => {
};

const init = () => {
console.log('Initiated!');
if (!muted) {
console.log('music not muted. toggle volume icon');
toggleVolumeIcon();
Expand Down

0 comments on commit a259a84

Please sign in to comment.