yet-another-react-lightbox 1.9.1 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugins/Zoom.js +10 -8
- package/package.json +1 -1
package/dist/plugins/Zoom.js
CHANGED
|
@@ -132,7 +132,9 @@ const ZoomContainer = ({ slide, offset, rect, render, carousel, animation, zoom:
|
|
|
132
132
|
const { subscribe } = useEvents();
|
|
133
133
|
const currentReduceMotion = useMotionPreference();
|
|
134
134
|
const { slideRect: currentSlideRect, maxSlideRect: currentMaxSlideRect } = getSlideRects(slide, carousel.imageFit === "cover" || ("imageFit" in slide && slide.imageFit === "cover"), zoomProps.maxZoomPixelRatio, currentContainerRect);
|
|
135
|
-
const currentMaxZoom = currentSlideRect.width
|
|
135
|
+
const currentMaxZoom = currentSlideRect.width
|
|
136
|
+
? Math.max(round(currentMaxSlideRect.width / currentSlideRect.width, 5), 1)
|
|
137
|
+
: 1;
|
|
136
138
|
const [state, setState] = React.useState({ zoom: 1, offsetX: 0, offsetY: 0 });
|
|
137
139
|
const refs = React.useRef({
|
|
138
140
|
state,
|
|
@@ -202,13 +204,6 @@ const ZoomContainer = ({ slide, offset, rect, render, carousel, animation, zoom:
|
|
|
202
204
|
}
|
|
203
205
|
}
|
|
204
206
|
}, [state.zoom, state.offsetX, state.offsetY]);
|
|
205
|
-
useEnhancedEffect(() => {
|
|
206
|
-
if (offset === 0) {
|
|
207
|
-
const { setMinZoom, setMaxZoom, maxZoom } = refs.current;
|
|
208
|
-
setMinZoom(state.zoom <= 1);
|
|
209
|
-
setMaxZoom(state.zoom >= maxZoom);
|
|
210
|
-
}
|
|
211
|
-
}, [offset, state.zoom]);
|
|
212
207
|
useEnhancedEffect(() => {
|
|
213
208
|
if (offset === 0) {
|
|
214
209
|
const { setMinZoom, setMaxZoom } = refs.current;
|
|
@@ -224,6 +219,13 @@ const ZoomContainer = ({ slide, offset, rect, render, carousel, animation, zoom:
|
|
|
224
219
|
}
|
|
225
220
|
return () => { };
|
|
226
221
|
}, [offset]);
|
|
222
|
+
useEnhancedEffect(() => {
|
|
223
|
+
if (offset === 0) {
|
|
224
|
+
const { setMinZoom, setMaxZoom, maxZoom } = refs.current;
|
|
225
|
+
setMinZoom(state.zoom <= 1);
|
|
226
|
+
setMaxZoom(state.zoom >= maxZoom);
|
|
227
|
+
}
|
|
228
|
+
}, [offset, state.zoom]);
|
|
227
229
|
const changeZoom = React.useCallback((value, rapid, dx, dy) => {
|
|
228
230
|
const { current } = refs;
|
|
229
231
|
const { state: { zoom }, containerRef, containerRect, maxZoom, } = current;
|