File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -735,7 +735,7 @@ export default function PagesHorizontalViewer({
735735 ) : null }
736736
737737 { /** Automatically Render Overlays **/ }
738- { page . pageLinks
738+ { page . pageLinks && imageDimensions [ index ]
739739 ? page . pageLinks
740740 . filter ( ( link ) => link . href . endsWith ( ".gif" ) )
741741 . map ( ( link , linkIndex ) => {
@@ -752,18 +752,27 @@ export default function PagesHorizontalViewer({
752752 const overlayWidth = x2 - x1 ;
753753 const overlayHeight = y2 - y1 ;
754754
755+ // Calculate the offset to center-align with the image
756+ const containerWidth =
757+ imageRefs . current [ index ] ?. parentElement
758+ ?. clientWidth || 0 ;
759+ const imageWidth =
760+ imageDimensions [ index ] . width ;
761+ const leftOffset =
762+ ( containerWidth - imageWidth ) / 2 ;
763+
755764 return (
756765 < img
757766 key = { `overlay-${ index } -${ linkIndex } ` }
758- src = { link . href } // Assuming the href points to a GIF or overlay image
767+ src = { link . href }
759768 alt = { `Overlay ${ index + 1 } ` }
760769 style = { {
761770 position : "absolute" ,
762771 top : y1 ,
763- left : x1 ,
772+ left : x1 + leftOffset ,
764773 width : `${ overlayWidth } px` ,
765774 height : `${ overlayHeight } px` ,
766- pointerEvents : "none" , // To ensure the overlay doesn't interfere with interaction
775+ pointerEvents : "none" ,
767776 } }
768777 />
769778 ) ;
Original file line number Diff line number Diff line change @@ -932,7 +932,7 @@ export default function PagesVerticalViewer({
932932 </ map >
933933 ) : null }
934934
935- { page . pageLinks
935+ { page . pageLinks && imageDimensions [ index ]
936936 ? page . pageLinks
937937 . filter ( ( link ) => link . href . endsWith ( ".gif" ) )
938938 . map ( ( link , linkIndex ) => {
@@ -949,6 +949,9 @@ export default function PagesVerticalViewer({
949949 const overlayWidth = x2 - x1 ;
950950 const overlayHeight = y2 - y1 ;
951951
952+ // Account for the padding on the outer container (px-4 md:px-8)
953+ const padding = isMobile ? 16 : 32 ; // 1rem = 16px (px-4), 2rem = 32px (px-8)
954+
952955 return (
953956 < img
954957 key = { `overlay-${ index } -${ linkIndex } ` }
@@ -957,7 +960,7 @@ export default function PagesVerticalViewer({
957960 style = { {
958961 position : "absolute" ,
959962 top : y1 ,
960- left : x1 ,
963+ left : x1 + padding ,
961964 width : `${ overlayWidth } px` ,
962965 height : `${ overlayHeight } px` ,
963966 pointerEvents : "none" ,
You can’t perform that action at this time.
0 commit comments