Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use currentSrc for imgs in <picture> tags #194

Merged
merged 1 commit into from
Nov 15, 2022

Conversation

fennifith
Copy link
Contributor

Summary

Issue #174 details a lack of support for differences in the selected image within a <picture> tag. In this case, the image's currentSrc reflects which of the available sources the browser decided to use.

In my case, the <img> tags lack any src whatsoever, so when used outside of the <picture> tags they will not display any image.

Result

I took a slightly more naive solution than what is described in #174 - any <img> tag in a <picture> structure now sets zoomed.src = original.currentSrc after cloning the element. This ensures that the zoomed image will reflect the same source as what was originally displayed in the <picture> tag, and eliminates any flicker in the transition when used with data-zoom-src.

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit a490d0b:

Sandbox Source
@medium-zoom/vanilla-example Configuration

Copy link
Owner

@francoischalifour francoischalifour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great! Thank you for the tests and stories as well @fennifith.

@francoischalifour
Copy link
Owner

Closes #174.

@francoischalifour francoischalifour merged commit 32ee39f into francoischalifour:master Nov 15, 2022
@francoischalifour
Copy link
Owner

🎉 This was released in v1.0.8.

@fennifith
Copy link
Contributor Author

Awesome - thank you! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants