francoischalifour / medium-zoom

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

Zoomed image appears behind the sidebar #182

Closed champagnealexandre closed 2 years ago

champagnealexandre commented 2 years ago

Bug description

A clear and concise description of what the bug is.

Zoomed image appears behind any existing sidebar.

I’ve tried using margins, but then the image doesn’t scale correctly on mobile.

I’ve also tried using a container, but the zoomed image appears off-screen.

How to reproduce

A list of the steps to reproduce the bug.

Using the following code:

const images = Array.from(document.querySelectorAll("img"));
images.forEach(img => {
  mediumZoom(img, {
    margin: 0,
    scrollOffset: 40,
    background: "#fff"
  });
});

in a website that has a sidebar.

Expected behavior

A clear and concise description of what you expected to happen.

The image should appear in front of the sidebar.

Reproducible example

For example,

image

Environment

francoischalifour commented 2 years ago

This is likely because the sidebar z-index value is higher than the zoomed image's. We explain how to increase the z-index value in the documentation.

Closing for now, feel free to reopen.

champagnealexandre commented 2 years ago

@francoischalifour wonderful, working fine now!

Thank you!