message timeouts

This commit is contained in:
Evan You 2022-01-23 19:46:58 +08:00
parent 69ced39496
commit 7853b82a4e

View File

@ -97,7 +97,8 @@ function completeRow() {
showMessage( showMessage(
['Genius', 'Magnificent', 'Impressive', 'Splendid', 'Great', 'Phew'][ ['Genius', 'Magnificent', 'Impressive', 'Splendid', 'Great', 'Phew'][
currentRowIndex currentRowIndex
] ],
2000
) )
} else if (currentRowIndex < board.length - 1) { } else if (currentRowIndex < board.length - 1) {
// go the next row // go the next row
@ -105,7 +106,7 @@ function completeRow() {
} else { } else {
// game over :( // game over :(
allowInput = false allowInput = false
showMessage(answer.toUpperCase()) showMessage(answer.toUpperCase(), -1)
} }
} else { } else {
shake() shake()
@ -113,11 +114,13 @@ function completeRow() {
} }
} }
function showMessage(msg: string) { function showMessage(msg: string, time = 1000) {
message = msg message = msg
if (time > 0) {
setTimeout(() => { setTimeout(() => {
message = '' message = ''
}, 1000) }, time)
}
} }
function shake() { function shake() {
@ -234,7 +237,7 @@ function shake() {
} }
.tile.filled .front { .tile.filled .front {
border-color: #999; border-color: #999;
animation: zoom .2s; animation: zoom 0.2s;
} }
.tile:not(.empty) { .tile:not(.empty) {
border: none; border: none;