Make game pick time consistent

This commit is contained in:
Sergey Stepanov 2023-04-27 14:49:28 +03:00
parent 30584b3faa
commit e50dc102bb
No known key found for this signature in database
GPG key ID: A56B4929BAA8556B
2 changed files with 11 additions and 7 deletions

View file

@ -467,6 +467,7 @@ body {
background-image: url('/static/img/screen_background5.png');
background-size: cover;
z-index: 1;
}
#menu-item-choice {

View file

@ -33,6 +33,8 @@ const gameList = (() => {
pickGame();
};
const pickDelayMs = 150
const pickGame = (index, hold) => {
let idx = undefined !== index ? index : gameIndex;
@ -42,7 +44,7 @@ const gameList = (() => {
if (idx >= games.length) idx = 0;
// transition menu box
listBox.style['transition'] = 'top 0.2s';
listBox.style['transition'] = `top ${pickDelayMs}ms`;
menuTop = MENU_TOP_POSITION - idx * 36;
listBox.style['top'] = `${menuTop}px`;
@ -57,7 +59,7 @@ const gameList = (() => {
listBox.querySelectorAll(`.menu-item span`)[idx].classList.add(cl);
}, 50)
gameIndex = idx;
gameIndex = idx;
};
const startGamePickerTimer = (upDirection) => {
@ -69,18 +71,19 @@ const gameList = (() => {
// keep rolling the game list if the button is pressed
gamePickTimer = setInterval(() => {
pickGame(gameIndex + shift, true);
}, 150);
}, pickDelayMs);
};
const stopGamePickerTimer = () => {
if (gamePickTimer === null) return;
clearInterval(gamePickTimer);
gamePickTimer = null;
let pick = listBox.querySelectorAll('.menu-item .pick-over')[0];
pick.classList.remove('pick-over');
pick.classList.add('pick');
const pick = listBox.querySelectorAll('.menu-item .pick-over')[0];
if (pick) {
pick.classList.remove('pick-over');
pick.classList.add('pick');
}
};
const onMenuPressed = (newPosition) => {