@@ -27,7 +27,6 @@ type Props = {
2727 onLoadError ?: ( ) => void ;
2828 containerStyle ?: CSSProperties ;
2929 contentContainerStyle ?: CSSProperties ;
30- /** Rotation angle for all pages (0, 90, 180, 270 degrees) */
3130 rotation ?: RotationDegrees ;
3231} ;
3332
@@ -216,6 +215,14 @@ function PDFPreviewer({
216215 }
217216 } , [ containerWidth , containerHeight , rotation ] ) ;
218217
218+ /**
219+ * Scroll back to the top whenever rotation changes so the list offset
220+ * is consistent regardless of how page dimensions change.
221+ */
222+ useLayoutEffect ( ( ) => {
223+ listRef . current ?. scrollTo ( 0 ) ;
224+ } , [ rotation ] ) ;
225+
219226 useLayoutEffect ( ( ) => {
220227 if ( ! containerRef . current ) {
221228 return undefined ;
@@ -260,7 +267,7 @@ function PDFPreviewer({
260267 style = { { ...styles . list , ...contentContainerStyle } }
261268 outerRef = { setListAttributes }
262269 width = { isSmallScreen ? pageWidth : containerWidth }
263- height = { containerHeight }
270+ height = { numPages === 1 && estimatedPageHeight < containerHeight ? estimatedPageHeight : containerHeight }
264271 itemCount = { numPages }
265272 itemSize = { calculatePageHeight }
266273 estimatedItemSize = { calculatePageHeight ( 0 ) }
@@ -269,7 +276,6 @@ function PDFPreviewer({
269276 estimatedPageHeight,
270277 calculatePageHeight,
271278 getDevicePixelRatio,
272- containerHeight,
273279 numPages,
274280 } }
275281 >
0 commit comments