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 = () => {
|
const updateIframeSizes = () => {
|
||||||
if (!articleContainer?.current || !props.article.body) return
|
if (!articleContainer?.current || !props.article.body) return
|
||||||
const iframes = articleContainer?.current?.querySelectorAll('iframe')
|
const iframes = articleContainer?.current?.querySelectorAll('iframe')
|
||||||
|
console.log('!!! iframes:', iframes)
|
||||||
if (!iframes) return
|
if (!iframes) return
|
||||||
const containerWidth = articleContainer.current?.offsetWidth
|
const containerWidth = articleContainer.current?.offsetWidth
|
||||||
iframes.forEach((iframe) => {
|
iframes.forEach((iframe) => {
|
||||||
|
@ -308,6 +309,8 @@ export const FullArticle = (props: Props) => {
|
||||||
const aspectRatio = width / height
|
const aspectRatio = width / height
|
||||||
iframe.style.width = `${containerWidth}px`
|
iframe.style.width = `${containerWidth}px`
|
||||||
iframe.style.height = `${Math.round(containerWidth / aspectRatio) + 40}px`
|
iframe.style.height = `${Math.round(containerWidth / aspectRatio) + 40}px`
|
||||||
|
} else {
|
||||||
|
iframe.style.height = `${containerWidth}px`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user