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

Zoom breaks when browser viewport size changes e.g. portrait to landscape or vice versa #17

Open
joyfulelement opened this issue Jul 19, 2020 · 2 comments
Assignees

Comments

@joyfulelement
Copy link

While testing the responsiveness of this plug-in with gatsby, I noticed the zoom capability will disappear after the browser viewport resolution is changed, e.g. portrait to landscape or vice versa. A common use case when viewing with mobile device.

By examine the DOM, before the viewport size change:

<span class="gatsby-resp-image-wrapper" ...>
  <span class="gatsby-resp-image-background-image" ...></span>
  <img
    class="gatsby-resp-image-image medium-zoom-image"
    src="..."
    srcset="..."
    "
    ...
  />
</span>

after the browser viewport resolution is changed, the class medium-zoom-image that use to be applied against <img> tag will disappear and hence the loss of the zoom functionality:

<span class="gatsby-resp-image-wrapper" ...>
  <span class="gatsby-resp-image-background-image" ...></span>
  <img
    class="gatsby-resp-image-image"
    src="..."
    srcset="..."
    "
    ...
  />
</span>

Current Workaround

While not ideal, the zoom functionality can be restored with another manual refresh after the viewport resolution change.

@JaeYeopHan JaeYeopHan self-assigned this Jul 20, 2020
@joyfulelement
Copy link
Author

After some more troubleshooting, I later found the issue above can be reproduced if the component is re-mounted. Looks like when the component mounts again, the class medium-zoom-image does not get apply.

@flashtheman
Copy link

Is there some workaround for this issue?

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

No branches or pull requests

3 participants