@@ -90,18 +90,18 @@ function ImageGallery({ images }: Props) {
90
90
91
91
const determineWrapperDimensions = (
92
92
image : { width : number ; height : number } ,
93
- carouselPadding : number ,
93
+ padding : number ,
94
94
) => {
95
95
const { innerWidth, innerHeight } = window
96
96
const aspectRatio = image . width / image . height
97
97
let wrapperX = 0
98
98
let wrapperY = 0
99
99
100
100
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 )
102
102
wrapperX = wrapperY * aspectRatio
103
103
} else {
104
- wrapperX = Math . min ( innerWidth - carouselPadding * 2 , image . width )
104
+ wrapperX = Math . min ( innerWidth - padding * 2 , image . width )
105
105
wrapperY = wrapperX / aspectRatio
106
106
}
107
107
@@ -113,11 +113,13 @@ function ImageGallery({ images }: Props) {
113
113
wrapperY : number ,
114
114
translateX : number ,
115
115
translateY : number ,
116
- zoomValue : number ,
116
+ zoom : number ,
117
117
) {
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
121
123
return { offsetX, offsetY }
122
124
}
123
125
0 commit comments