question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Medium zoom not using data-zoom-target for images with srcset

See original GitHub issue

I’m using medium-zoom on some responsive images (with srcset), and I’m running into some weird behaviour. I’m using a script to calculate the most appropriate image size for the clients viewport, and I set that as the data-zoom-target attribute.

But when zooming it seems to be zooming to the wrong size (as instead of enlarging to fill the viewport, the image shrinks). I’m not sure what exactly’s going wrong. Is this a bug, or am I doing something wrong here?

PR implementing the above: https://github.com/ismay/ismaywolff.nl/pull/718 Live url demonstrating the above: https://deploy-preview-718--ismaywolff.netlify.com/work/mould

Unzoomed:

screen shot 2017-11-04 at 14 05 15

Zoomed:

screen shot 2017-11-04 at 14 05 19

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
francoischalifourcommented, Nov 11, 2017

Thanks for the explanation, that’s quite a good way of solving this!

If you want to reduce jank when unzooming, maybe replace the srcset with the initial src attribute before unzooming? (the one you cloned the initial image with). That’d be fewer pixels to translate back.

I’ll definitely have a closer look at your implementation soon. Thanks for your research!

0reactions
gfellerphcommented, Feb 15, 2018

How about applying the new sizes attribute (something like sizes="100vw") after the image has been zoomed? This way the animation would be smooth. The zoomed image might be blurry at first, but will be replaced by the appropriate sized image after download.

Another approach would be setting the sizes attribute immediately, wait for the image to download, then animate but I’m not sure if it’s possible to detect that a new srcset image has been loaded.

Read more comments on GitHub >

github_iconTop Results From Across the Web

medium-zoom | Yarn - Package Manager
medium -zoom. A JavaScript library for zooming images like Medium. version MIT license downloads gzip size no dependencies travis. Medium Zoom Demo
Read more >
Srcset and Sizes: Responsive Images - AnKiT KaMbOj - Medium
It's no longer needed to serve that big hero image on a small screen. With srcset and sizes you can offer a smaller...
Read more >
HTML5 picture tag issue related to zoom - Stack Overflow
While zooming images, images that are given in the media query get displayed instead of the images inside the srcset that given along...
Read more >
Sending a screen capture, file, or photo - Zoom Support
The image, and any accompanying text, will be displayed to all recipients. Use the camera to take and send a photo. Sign in...
Read more >
gatsby-remark-images-medium-zoom-plugin
gatsby-remark-images-medium-zoom-plugin npm version medium-zoom plugin for gatsby with Use Case gatsby-starter-bee Install How…
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found