Fix tall images cropped in lightbox

The wrapRef div had no dimensions, so max-w-full/max-h-full on the img
resolved against the image's own natural size rather than the available
space. Give wrapRef full width/height so percentage constraints work
correctly against the padded slot area.
This commit is contained in:
Chad Curtis
2026-03-17 09:59:04 -05:00
parent d955473c3c
commit f17bc899c8
+2 -3
View File
@@ -799,16 +799,15 @@ function LightboxImage({ url, isLoaded, onLoad, onSwipeBlocked }: {
onMouseLeave={handleMouseUp}
style={{ cursor: scale.current > 1 ? 'grab' : 'default' }}
>
<div ref={wrapRef} style={{ transformOrigin: 'center center', willChange: 'transform' }}>
<div ref={wrapRef} style={{ transformOrigin: 'center center', willChange: 'transform', width: '100%', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<img
ref={imgRef}
src={src}
alt=""
className={cn(
'max-w-full max-h-full object-contain select-none transition-opacity duration-300',
'block max-w-full max-h-full object-contain select-none transition-opacity duration-300',
isLoaded ? 'opacity-100' : 'opacity-0',
)}
style={{ display: 'block', maxHeight: '100dvh' }}
onLoad={handleLoaded}
onError={onError}
draggable={false}