mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-25 19:13:52 +00:00
Make game picking less ugly
This commit is contained in:
parent
dc48c93804
commit
30584b3faa
2 changed files with 23 additions and 11 deletions
|
|
@ -534,6 +534,10 @@ body {
|
|||
animation: horizontally 4s linear infinite alternate;
|
||||
}
|
||||
|
||||
.menu-item div .pick-over {
|
||||
overflow: unset;
|
||||
}
|
||||
|
||||
|
||||
@-moz-keyframes horizontally {
|
||||
0% {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ const gameList = (() => {
|
|||
pickGame();
|
||||
};
|
||||
|
||||
const pickGame = (index) => {
|
||||
const pickGame = (index, hold) => {
|
||||
let idx = undefined !== index ? index : gameIndex;
|
||||
|
||||
// check boundaries
|
||||
|
|
@ -43,18 +43,21 @@ const gameList = (() => {
|
|||
|
||||
// transition menu box
|
||||
listBox.style['transition'] = 'top 0.2s';
|
||||
|
||||
menuTop = MENU_TOP_POSITION - idx * 36;
|
||||
listBox.style['top'] = `${menuTop}px`;
|
||||
|
||||
// overflow marquee
|
||||
let pick = document.querySelectorAll('.menu-item .pick')[0];
|
||||
if (pick) {
|
||||
pick.classList.remove('pick');
|
||||
}
|
||||
document.querySelectorAll(`.menu-item span`)[idx].classList.add('pick');
|
||||
const cl = hold ? 'pick-over' : 'pick'
|
||||
let pick = listBox.querySelectorAll('.menu-item .pick, .menu-item .pick-over')[0];
|
||||
|
||||
gameIndex = idx;
|
||||
setTimeout(() => { // overflow marquee
|
||||
if (pick) {
|
||||
pick.classList.remove('pick');
|
||||
pick.classList.remove('pick-over')
|
||||
}
|
||||
listBox.querySelectorAll(`.menu-item span`)[idx].classList.add(cl);
|
||||
}, 50)
|
||||
|
||||
gameIndex = idx;
|
||||
};
|
||||
|
||||
const startGamePickerTimer = (upDirection) => {
|
||||
|
|
@ -65,14 +68,19 @@ const gameList = (() => {
|
|||
// velocity?
|
||||
// keep rolling the game list if the button is pressed
|
||||
gamePickTimer = setInterval(() => {
|
||||
pickGame(gameIndex + shift);
|
||||
}, 200);
|
||||
pickGame(gameIndex + shift, true);
|
||||
}, 150);
|
||||
};
|
||||
|
||||
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 onMenuPressed = (newPosition) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue