Skip to content

Commit

Permalink
Fixed bug where max-height was visibly changing on resize to greater …
Browse files Browse the repository at this point in the history
…than 768 pixels
  • Loading branch information
cmhhelgeson committed Jan 4, 2024
1 parent e559c09 commit 126890e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ const MainLayout: React.FunctionComponent<AppProps> = ({
prevWindowWidth.current = window.innerWidth;
panelContentsRef.current.style.maxHeight =
panelContentsRef.current.scrollHeight + 'px';
// Prevent visible height change on resize behind window.innerWidth > 768
panelContentsRef.current.style.transition = 'max-height 0s';
}
// Else when the window resizes to less than 768 pixels
// and we haven't already gone under 768 pixels on the previous resize,
// then set the height of panelContents to 0.
if (window.innerWidth <= 768 && prevWindowWidth.current > 768) {
panelContentsRef.current.style.maxHeight = '0px';
panelContentsRef.current.style.transition = 'max-height 0.3s ease-out';
}
};
window.addEventListener('resize', resizeListener);
Expand Down

0 comments on commit 126890e

Please sign in to comment.