Skip to content

Commit 4520688

Browse files
gordoneySiarhei Balonikau
andauthored
fix/epmgcip-143/fix-slider-zoom-adjustment (#25)
Co-authored-by: Siarhei Balonikau <[email protected]>
1 parent 5985490 commit 4520688

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/components/organisms/ImageGallery/ImageGallery.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,18 @@ function ImageGallery({ images }: Props) {
9090

9191
const determineWrapperDimensions = (
9292
image: { width: number; height: number },
93-
carouselPadding: number,
93+
padding: number,
9494
) => {
9595
const { innerWidth, innerHeight } = window
9696
const aspectRatio = image.width / image.height
9797
let wrapperX = 0
9898
let wrapperY = 0
9999

100100
if (image.height > window.innerHeight && image.width < window.innerWidth) {
101-
wrapperY = Math.min(innerHeight - carouselPadding * 2, image.height)
101+
wrapperY = Math.min(innerHeight - padding * 2, image.height)
102102
wrapperX = wrapperY * aspectRatio
103103
} else {
104-
wrapperX = Math.min(innerWidth - carouselPadding * 2, image.width)
104+
wrapperX = Math.min(innerWidth - padding * 2, image.width)
105105
wrapperY = wrapperX / aspectRatio
106106
}
107107

@@ -113,11 +113,13 @@ function ImageGallery({ images }: Props) {
113113
wrapperY: number,
114114
translateX: number,
115115
translateY: number,
116-
zoomValue: number,
116+
zoom: number,
117117
) {
118-
const removeShift = 1 + 1 / zoomValue
119-
const offsetX = (wrapperX / 100) * (translateX - 50) * removeShift
120-
const offsetY = (wrapperY / 100) * (translateY - 50) * removeShift
118+
const yetAnotherReactLightboxShift = 1 - 1 / zoom
119+
const offsetX =
120+
((wrapperX / 100) * (translateX - 50)) / yetAnotherReactLightboxShift
121+
const offsetY =
122+
((wrapperY / 100) * (translateY - 50)) / yetAnotherReactLightboxShift
121123
return { offsetX, offsetY }
122124
}
123125

0 commit comments

Comments
 (0)