Magento – Magento 2 product gallery doesn’t close on iPhone

fotoramagallerymagento2product

I'm using Magento 2.2.1, with a theme that has magento blank theme as parent. I'm having a problem on iPhone 6, but not on Windows mobile or Android. Basically when I go on the product page, and open the product gallery images, I can't close the gallery anymore when I press the X, as I sayd, this happens only on iPhone. The gallery used is a Fotorama, is the default one, anyone has any idea what it might be?

Best Answer

Override fotorama.js in your custom theme at app/design/<vendor>/<custom_theme>/web/fotorama/fotorama.js, you can copy this file from \lib\web\fotorama\fotorama.js and replace code as per below at line no. 1220

From

function stubEvent($el, eventType) {
    $el.on(eventType, function (e) {
        stopEvent(e, true);

        return false;
    });
}

To

function stubEvent($el, eventType) {
     var isIOS = /iP(ad|hone|od)/i.test(window.navigator.userAgent);

    if (isIOS && eventType === 'touchend') {
        $el.on('touchend', function(e){
            $DOCUMENT.trigger('mouseup', e);
        })
    }

    $el.on(eventType, function (e) {
        stopEvent(e, true);

        return false;
    });
}

Note: This is work for me in Magento 2.2.0 version, hopefully this will work in Magento 2.2.1 and other Magento 2.2x versions as well.

Related Topic