Skip to content

Commit b920940

Browse files
authoredNov 14, 2022
fix: ensure zooming out doesn't happen (#176)
1 parent dd01423 commit b920940

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎src/medium-zoom.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ const mediumZoom = (selector, options = {}) => {
244244
: zoomTarget.naturalHeight || viewportHeight
245245
const { top, left, width, height } = zoomTarget.getBoundingClientRect()
246246

247-
const scaleX = Math.min(naturalWidth, viewportWidth) / width
248-
const scaleY = Math.min(naturalHeight, viewportHeight) / height
247+
const scaleX = Math.min(Math.max(width, naturalWidth), viewportWidth) / width
248+
const scaleY = Math.min(Math.max(height, naturalHeight), viewportHeight) / height
249249
const scale = Math.min(scaleX, scaleY)
250250
const translateX =
251251
(-left +

0 commit comments

Comments
 (0)
Please sign in to comment.