fix: btn list
This commit is contained in:
parent
b6837ee8e0
commit
2a29e378f2
1 changed files with 14 additions and 13 deletions
27
src/btn.ts
27
src/btn.ts
|
@ -93,28 +93,29 @@ export class BtnList {
|
||||||
const btnParent = document.querySelector('div') as HTMLDivElement
|
const btnParent = document.querySelector('div') as HTMLDivElement
|
||||||
const shadow = attachShadow(btnParent)
|
const shadow = attachShadow(btnParent)
|
||||||
|
|
||||||
try {
|
|
||||||
const anchorDiv = this.getBtnParent()
|
|
||||||
const { width, top, left } = anchorDiv.getBoundingClientRect()
|
|
||||||
btnParent.style.width = `${width}px`
|
|
||||||
btnParent.style.top = `${top}px`
|
|
||||||
btnParent.style.left = `${left}px`
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// style the shadow DOM
|
// style the shadow DOM
|
||||||
const style = document.createElement('style')
|
const style = document.createElement('style')
|
||||||
style.innerText = btnListCss
|
style.innerText = btnListCss
|
||||||
shadow.append(style)
|
shadow.append(style)
|
||||||
|
|
||||||
// hide buttons using the shadow DOM
|
// hide buttons using the shadow DOM
|
||||||
const newParent = btnParent.cloneNode(false) as HTMLDivElement
|
|
||||||
newParent.append(...this.list.map(e => cloneBtn(e)))
|
|
||||||
shadow.append(newParent)
|
|
||||||
const slot = document.createElement('slot')
|
const slot = document.createElement('slot')
|
||||||
shadow.append(slot)
|
shadow.append(slot)
|
||||||
|
|
||||||
|
const newParent = document.createElement('div')
|
||||||
|
newParent.append(...this.list.map(e => cloneBtn(e)))
|
||||||
|
shadow.append(newParent)
|
||||||
|
|
||||||
|
try {
|
||||||
|
const anchorDiv = this.getBtnParent()
|
||||||
|
const { width, top, left } = anchorDiv.getBoundingClientRect()
|
||||||
|
newParent.style.width = `${width}px`
|
||||||
|
newParent.style.top = `${top}px`
|
||||||
|
newParent.style.left = `${left}px`
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
|
||||||
return btnParent
|
return btnParent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue