fix iframe size in article (#389)

This commit is contained in:
Ilya Y 2024-02-01 23:46:54 +03:00 committed by GitHub
parent 1d5bc80318
commit e4d8aafb9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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`
}
})
}