fix scroll position restore for Firefox

This commit is contained in:
2020-06-10 17:55:50 +02:00
parent 268c683ad3
commit ff4f081e7c
2 changed files with 8 additions and 4 deletions

View File

@@ -48,7 +48,7 @@ export class TextRenderingService {
[SectionType.Chorus]: 0, [SectionType.Chorus]: 0,
[SectionType.Verse]: 0, [SectionType.Verse]: 0,
}; };
const sections = arrayOfLines.reduce((array, line) => { return arrayOfLines.reduce((array, line) => {
const type = this.getSectionTypeOfLine(line); const type = this.getSectionTypeOfLine(line);
if (line.match(this.regexSection)) return [...array, { if (line.match(this.regexSection)) return [...array, {
type: type, type: type,
@@ -58,8 +58,6 @@ export class TextRenderingService {
array[array.length - 1].lines.push(this.getLineOfLineText(line)); array[array.length - 1].lines.push(this.getLineOfLineText(line));
return array; return array;
}, [] as Section[]); }, [] as Section[]);
return sections;
} }
private getLineOfLineText(text: string): Line { private getLineOfLineText(text: string): Line {
@@ -104,7 +102,12 @@ export class TextRenderingService {
chords.push(chord); chords.push(chord);
} }
return chords;
const chordCount = chords.reduce((acc: number, cur: Chord) => acc + cur.length, 0);
const lineCount = chordLine.replace(/\s/g, "").length;
const isChrod = chordCount * 2 > lineCount;
return isChrod ? chords : [];
} }
} }

View File

@@ -46,6 +46,7 @@ export class SongListComponent implements OnInit, OnDestroy {
); );
setTimeout(() => this.scrollService.restoreScrollPositionFor('songlist'), 100); setTimeout(() => this.scrollService.restoreScrollPositionFor('songlist'), 100);
setTimeout(() => this.scrollService.restoreScrollPositionFor('songlist'), 300);
} }
public ngOnDestroy(): void { public ngOnDestroy(): void {