|
@@ -84,27 +84,29 @@ export const randomScoreElement = (element?: string) => {
|
|
|
export const elementDirection = (type: string, index: number) => {
|
|
|
const prefix = setting.element === 'jianpu' ? 'j-' : 'f-';
|
|
|
let ele = '';
|
|
|
- let i = Number(index);
|
|
|
+ let i = 0;
|
|
|
const tempoList = setting.tempo;
|
|
|
+ const toIndex = tempoList.findIndex((t: any) => Number(t) === index);
|
|
|
if (type === 'up') {
|
|
|
- if (index <= 0) {
|
|
|
+ if (toIndex <= 0) {
|
|
|
ele = tempoList[tempoList.length - 1];
|
|
|
i = tempoList.length - 1;
|
|
|
} else {
|
|
|
- ele = tempoList[index - 1];
|
|
|
- i = index - 1;
|
|
|
+ ele = tempoList[toIndex - 1];
|
|
|
+ i = toIndex - 1;
|
|
|
}
|
|
|
} else if (type === 'down') {
|
|
|
- if (index >= tempoList.length - 1) {
|
|
|
+ // console.log(tempoList, '121212', index);
|
|
|
+ // console.log(toIndex);
|
|
|
+ if (toIndex >= tempoList.length - 1) {
|
|
|
ele = tempoList[0];
|
|
|
i = 0;
|
|
|
} else {
|
|
|
- ele = tempoList[index + 1];
|
|
|
- i = index + 1;
|
|
|
+ ele = tempoList[toIndex + 1];
|
|
|
+ i = toIndex + 1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- console.log(ele, Number(index), type, i);
|
|
|
return {
|
|
|
url: prefix + ele + '.png',
|
|
|
index: Number(ele)
|