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

Zoomed image not closing in browsers not supporting srcset (IE11 and Edge 13-15) #180

Open
jaxtheking opened this issue Aug 27, 2021 · 0 comments

Comments

@jaxtheking
Copy link

I know (and understand) this issue won't get much attention, but I'd still like to file a report for those poor souls who still have to try supporting old browsers like IE11. Apart from the fact this library is awesome, I also chose it because it states support for IE.

In browsers not supporting the srcset attribute, after clicking on an image to open it, the cloned image does not animate at all; furthermore, one can't close the modal which has become stuck.
This is due to the onload event not firing in browsers not supporting srcset, therefore the _animate() function is never called and the opened event never fired.

For users experiencing the same issue, this can be easily fixed by removing the srcset attribute upon clicking the image:

var imageZoom = mediumZoom(my_images);

imageZoom.on('open', (evt) => {
    // use your methods below to detect browsers not supporting srcset
    if (browser.is('msie') || browser.supports('respImages')) {
        var img = this.imageZoom.getZoomedImage();
        img.removeAttribute('srcset');
    }
});

I guess a better way would be adding a responsive image polyfill to the project, but I thought it'd be an overkill in my case.

Last possible solution would be for the maintainer to add a basic check for responsive images support:

function respImagesSupport() {
  var testImage = document.createElement('img');
  return ('sizes' in testImage) && ('srcset' in testImage);
}

then modify the promise returned by the open() function to something like this:

...
if (active.original.getAttribute('data-zoom-src') && respImagesSupport()) {
  ...
} else if (active.original.hasAttribute('srcset') && respImagesSupport()) {
  ...
} else {
  _animate();
}
...

so that _animate() finally gets called in these old browsers too.

I hope this helps anyone.
Luca

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

1 participant