fix: PDF download when the piano keyboard is open

This commit is contained in:
Xmader 2021-01-27 11:31:09 -05:00
parent e9ed0812b9
commit eda8342a3d
No known key found for this signature in database
GPG Key ID: A20B97FB9EB730E4
1 changed files with 7 additions and 4 deletions

View File

@ -105,9 +105,12 @@ export abstract class SheetInfo {
export class SheetInfoInPage extends SheetInfo {
constructor (private document: Document) { super() }
private get sheet0Img (): HTMLImageElement | null {
return this.document.querySelector('img[src*=score_]')
}
get pageCount (): number {
const sheet0Img = this.document.querySelector('img[src*=score_]')
const sheet0Div = sheet0Img?.parentElement
const sheet0Div = this.sheet0Img?.parentElement
if (!sheet0Div) {
throw new Error('no sheet images found')
}
@ -116,8 +119,8 @@ export class SheetInfoInPage extends SheetInfo {
get thumbnailUrl (): string {
// url to the image of the first page
const el = this.document.querySelector('link[as=image]') as HTMLLinkElement
const url = el.href
const el = this.document.querySelector<HTMLLinkElement>('link[as=image]')
const url = (el?.href || this.sheet0Img?.src) as string
return url.split('@')[0]
}
}