mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-01-23 02:34:42 +00:00
Make game pick time consistent
This commit is contained in:
parent
30584b3faa
commit
e50dc102bb
2 changed files with 11 additions and 7 deletions
|
|
@ -467,6 +467,7 @@ body {
|
|||
|
||||
background-image: url('/static/img/screen_background5.png');
|
||||
background-size: cover;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
#menu-item-choice {
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue