francoischalifour / medium-zoom

🔎🖼 A JavaScript library for zooming images like Medium
https://medium-zoom.francoischalifour.com
MIT License
3.58k stars 161 forks source link

Cannot close when used in a container that can be scrolled . #160

Closed guangzan closed 3 years ago

guangzan commented 3 years ago

Bug description

The scroll bar is not in the body. I use it in a container that can be scrolled. Medium zoom acts on the image of this container. When the image is opened, it cannot be closed by scrolling, and the container cannot be scrolled.

Expected behavior

It can be closed when scrolling .

francoischalifour commented 3 years ago

Can you please replicate the behavior in this sandbox?

guangzan commented 3 years ago

Like this sandbox . Thanks.

francoischalifour commented 3 years ago

This is expected because we append the zoomed image to the body, which doesn't have any scroll padding in that case.

As a workaround, you can increase the body height when an image is zoomed (.medium-zoom--opened). I created an example in this sandbox.

guangzan commented 3 years ago

Thank you so much .