WaitUntilOnPage: respond to window resizing or zooming.

This commit is contained in:
infinite-persistence 2021-07-05 11:56:36 +08:00
parent bb8fb038ca
commit 033b03e6e4
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -62,7 +62,11 @@ export default function WaitUntilOnPage(props: Props) {
if (ref && ref.current && !shouldRender) { if (ref && ref.current && !shouldRender) {
window.addEventListener('scroll', handleDisplayingRef); window.addEventListener('scroll', handleDisplayingRef);
return () => window.removeEventListener('scroll', handleDisplayingRef); window.addEventListener('resize', handleDisplayingRef);
return () => {
window.removeEventListener('scroll', handleDisplayingRef);
window.removeEventListener('resize', handleDisplayingRef);
};
} }
}, [ref, setShouldRender, shouldRender, shouldElementRender]); }, [ref, setShouldRender, shouldRender, shouldElementRender]);