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

PDP image switching not working on IE11 #1705

Closed
chippleh1392 opened this issue Jun 30, 2020 · 0 comments
Closed

PDP image switching not working on IE11 #1705

chippleh1392 opened this issue Jun 30, 2020 · 0 comments

Comments

@chippleh1392
Copy link

Expected behavior

On the product page, clicking an image thumbnail should swap the main image to the selected thumbnail image.

Actual behavior

On IE11, clicking the thumbnail results in nothing happening

Steps to reproduce behavior

On IE11, go to any product page that has more than 1 image, click a thumbnail image that is different from the currently selected image.

Comments

I investigated this and it appears that IE11's way of setting the main image using inline css (background-image property) is not compatible with the EasyZoom swap() function which is called in the swapMainImage() function in image-gallery.js. EasyZoom is specifically looking to update the image's src and srcset attributes. I implemented a fix just using an IE11 detection check and updating the needed image attributes with jQuery.

swapMainImage() {
    // ie11 fix
    let isIE11 = !!window.MSInputMethodContext && !!document.documentMode; // detect if ie11
    
    if (isIE11 == true) {
        this.$mainImage.find('img').css('background-image', `url('${this.currentImage.mainImageUrl}')`);
        this.$mainImage.find('a').attr('href', this.currentImage.mainImageUrl);
    } else { // if not ie11, perform easyzoom swap
        this.easyzoom.data('easyZoom').swap(
            this.currentImage.mainImageUrl,
            this.currentImage.zoomImageUrl,
            this.currentImage.mainImageSrcset,
        );
    }

    this.$mainImage.attr({
        'data-zoom-image': this.currentImage.zoomImageUrl,
    });
}
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

2 participants