This commit is contained in:
keyan 2023-12-17 13:23:52 -06:00
parent 69004168e0
commit fc3f46a343
1 changed files with 6 additions and 0 deletions

View File

@ -44,11 +44,17 @@ export default memo(function Text ({ nofollow, imgproxyUrls, children, tab, ...o
setOverflowing(container.scrollHeight > window.innerHeight * 2) setOverflowing(container.scrollHeight > window.innerHeight * 2)
} }
let resizeObserver
if (!overflowing && 'ResizeObserver' in window) {
resizeObserver = new window.ResizeObserver(checkOverflow).observe(container)
}
window.addEventListener('resize', checkOverflow) window.addEventListener('resize', checkOverflow)
checkOverflow() checkOverflow()
return () => { return () => {
window.removeEventListener('resize', checkOverflow) window.removeEventListener('resize', checkOverflow)
resizeObserver?.disconnect()
} }
}, [containerRef.current, setOverflowing]) }, [containerRef.current, setOverflowing])