pull/502/head
Pete Matsyburka 4 months ago
parent 6f7b9b1ebf
commit 708b8afdf5

@ -1,14 +1,12 @@
export default class extends HTMLElement { export default class extends HTMLElement {
connectedCallback () { connectedCallback () {
this.image.addEventListener('load', (e) => { const image = this.querySelector('img')
this.image.setAttribute('width', e.target.naturalWidth)
this.image.setAttribute('height', e.target.naturalHeight) image.addEventListener('load', (e) => {
image.setAttribute('width', e.target.naturalWidth)
image.setAttribute('height', e.target.naturalHeight)
this.style.aspectRatio = `${e.target.naturalWidth} / ${e.target.naturalHeight}` this.style.aspectRatio = `${e.target.naturalWidth} / ${e.target.naturalHeight}`
}) })
} }
get image () {
return this.querySelector('img')
}
} }

Loading…
Cancel
Save