fix iframe size in article (#389)
This commit is contained in:
parent
1d5bc80318
commit
e4d8aafb9b
|
@ -294,6 +294,7 @@ export const FullArticle = (props: Props) => {
|
|||
const updateIframeSizes = () => {
|
||||
if (!articleContainer?.current || !props.article.body) return
|
||||
const iframes = articleContainer?.current?.querySelectorAll('iframe')
|
||||
console.log('!!! iframes:', iframes)
|
||||
if (!iframes) return
|
||||
const containerWidth = articleContainer.current?.offsetWidth
|
||||
iframes.forEach((iframe) => {
|
||||
|
@ -308,6 +309,8 @@ export const FullArticle = (props: Props) => {
|
|||
const aspectRatio = width / height
|
||||
iframe.style.width = `${containerWidth}px`
|
||||
iframe.style.height = `${Math.round(containerWidth / aspectRatio) + 40}px`
|
||||
} else {
|
||||
iframe.style.height = `${containerWidth}px`
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user