fix: btns position

This commit is contained in:
Xmader 2021-01-21 23:40:53 -05:00
parent d33c06c892
commit b5477a4059
No known key found for this signature in database
GPG Key ID: A20B97FB9EB730E4
1 changed files with 4 additions and 2 deletions

View File

@ -15,13 +15,13 @@ export enum ICON {
} }
const getBtnContainer = (): HTMLDivElement => { const getBtnContainer = (): HTMLDivElement => {
const els = [...document.querySelectorAll('*')].reverse() const els = [...document.querySelectorAll('span')]
const el = els.find(b => { const el = els.find(b => {
const text = b?.textContent?.replace(/\s/g, '') || '' const text = b?.textContent?.replace(/\s/g, '') || ''
return text.includes('Download') || text.includes('Print') return text.includes('Download') || text.includes('Print')
}) as HTMLDivElement | null }) as HTMLDivElement | null
const btnParent = el?.parentElement?.parentElement as HTMLDivElement | undefined const btnParent = el?.parentElement?.parentElement as HTMLDivElement | undefined
if (!btnParent) throw new Error('btn parent not found') if (!btnParent || !(btnParent instanceof HTMLDivElement)) throw new Error('btn parent not found')
return btnParent return btnParent
} }
@ -139,6 +139,8 @@ export class BtnList {
newParent.append(...this.list.map(e => cloneBtn(e))) newParent.append(...this.list.map(e => cloneBtn(e)))
shadow.append(newParent) shadow.append(newParent)
// default position
newParent.style.top = '0px'
try { try {
const anchorDiv = this.getBtnParent() const anchorDiv = this.getBtnParent()
const pos = () => this._positionBtns(anchorDiv, newParent) const pos = () => this._positionBtns(anchorDiv, newParent)