Skip to content

Commit

Permalink
dynamically update container height
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardoj committed Jun 28, 2024
1 parent 1abc4ed commit 941cfb4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/PDFPreviewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,19 @@ function PDFPreviewer({
}, [isPasswordInvalid, attemptPDFLoad, setIsPasswordInvalid, renderPasswordForm]);

useLayoutEffect(() => {
setContainerWidth(containerRef.current?.clientWidth ?? 0);
setContainerHeight(containerRef.current?.clientHeight ?? 0);
if (!containerRef.current) {
return;
}
const resizeObserver = new ResizeObserver(() => {
if (!containerRef.current) {
return;
}
setContainerWidth(containerRef.current.clientWidth);
setContainerHeight(containerRef.current.clientHeight);
});
resizeObserver.observe(containerRef.current);

return resizeObserver.disconnect;

Check failure on line 246 in src/PDFPreviewer.tsx

View workflow job for this annotation

GitHub Actions / checks

Arrow function expected no return value
}, []);

return (
Expand Down

0 comments on commit 941cfb4

Please sign in to comment.