|
@@ -749,34 +749,30 @@ export const setStepIndex = (osmd: any, num: number, prev?: number) => {
|
|
}
|
|
}
|
|
|
|
|
|
export const getIndex = (times: any[], currentTime: Number) => {
|
|
export const getIndex = (times: any[], currentTime: Number) => {
|
|
- // console.log(currentTime)
|
|
|
|
- if (currentTime > state.times[state.times.length - 1].endtime) {
|
|
|
|
- return -1
|
|
|
|
- }
|
|
|
|
- let index = 0
|
|
|
|
- const ftime = times.filter((n, fi) => {
|
|
|
|
- const p: any = times[fi - 1]
|
|
|
|
- return p?.skipNextNote === false
|
|
|
|
- })
|
|
|
|
- for (let i = 0; i < ftime.length; i++) {
|
|
|
|
- const item = ftime[i]
|
|
|
|
- const prevItem = ftime[i - 1]
|
|
|
|
- if (currentTime >= item.time) {
|
|
|
|
- if (!prevItem || item.time != prevItem.time) {
|
|
|
|
- index = item.i
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- break
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (state.sectionStatus && state.section.length === 2) {
|
|
|
|
- // 限制不超过此范围
|
|
|
|
- const startSection = state.befireSection || state.section[0]
|
|
|
|
- index = Math.min(Math.max(index, startSection.i), state.section[1].i)
|
|
|
|
- // console.log('endIndex', index)
|
|
|
|
- }
|
|
|
|
- return index
|
|
|
|
-}
|
|
|
|
|
|
+ // console.log(currentTime)
|
|
|
|
+ if (currentTime > state.times[state.times.length - 1].endtime) {
|
|
|
|
+ return state.times.length - 1;
|
|
|
|
+ }
|
|
|
|
+ let index = 0;
|
|
|
|
+ for (let i = 0; i < times.length; i++) {
|
|
|
|
+ const item = times[i];
|
|
|
|
+ const prevItem = times[i - 1];
|
|
|
|
+ if (currentTime >= item.time) {
|
|
|
|
+ if (!prevItem || item.time != prevItem.time) {
|
|
|
|
+ index = item.i;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (state.sectionStatus && state.section.length === 2) {
|
|
|
|
+ // 限制不超过此范围
|
|
|
|
+ const startSection = state.befireSection || state.section[0];
|
|
|
|
+ index = Math.min(Math.max(index, startSection.i), state.section[1].i);
|
|
|
|
+ // console.log('endIndex', index)
|
|
|
|
+ }
|
|
|
|
+ return index;
|
|
|
|
+};
|
|
|
|
|
|
export const getSlursNote = (_note: any, pos?: 'start' | 'end') => {
|
|
export const getSlursNote = (_note: any, pos?: 'start' | 'end') => {
|
|
const note: any =
|
|
const note: any =
|
|
@@ -847,18 +843,19 @@ export const getNoteByMeasuresSlursStart = (note: any) => {
|
|
}
|
|
}
|
|
|
|
|
|
export const getActtiveNoteByTimes = (evt: MouseEvent) => {
|
|
export const getActtiveNoteByTimes = (evt: MouseEvent) => {
|
|
- const el = (evt.target as HTMLDivElement)?.dataset
|
|
|
|
- // console.log(state)
|
|
|
|
|
|
+ const el = (evt.target as HTMLDivElement)?.dataset;
|
|
|
|
+ // console.log(state)
|
|
|
|
|
|
- const data: any = {}
|
|
|
|
- for (const time of state.times) {
|
|
|
|
- if (time.id) {
|
|
|
|
- data[time.id] = time
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- const activeNote = data[el.id || '']
|
|
|
|
- return activeNote
|
|
|
|
-}
|
|
|
|
|
|
+ const data: any = {};
|
|
|
|
+ for (const time of state.times) {
|
|
|
|
+ if (time.id && !data[time.id]) {
|
|
|
|
+ data[time.id] = time;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ const activeNote = data[el.id || ""];
|
|
|
|
+ // state.timesById = data
|
|
|
|
+ return activeNote;
|
|
|
|
+};
|
|
|
|
|
|
const getPrevHasSourceNote = (note: any) => {
|
|
const getPrevHasSourceNote = (note: any) => {
|
|
const indexOf = Math.max(state.times.indexOf(note) - 1, 0)
|
|
const indexOf = Math.max(state.times.indexOf(note) - 1, 0)
|