Home Forums WoodMart support forum Product image flip on mobile device (show second image on hover)

Product image flip on mobile device (show second image on hover)

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #604518

    tmo.trnka
    Participant

    Please i would like to flip images when someone touch product on mobile. I just want to have same effect like on desktop when i went to product with cursor, product hover and IMAGE SWAP.

    #604562

    Hello,

    Navigate to Theme Settings > Products archive > Products styles and enable Hover image option https://prnt.sc/VgIGETXXJ3Ms

    And make sure you uploaded Product Gallery Images for product https://prnt.sc/0al0om0vL4ul

    Best Regards

    #604564

    tmo.trnka
    Participant

    yeah that works of cource, but only on desktop devicer as i write here… not working on mobile devices

    #604568

    tmo.trnka
    Participant

    ok i got it, thanks to chatgpt… for someone who would like to have hover on phone, there is a code…

    custom JS
    // Function to initialize the effect
    function initProductHoverEffect() {
    document.querySelectorAll(‘.product-wrapper’).forEach(item => {
    item.addEventListener(‘touchstart’, function () {
    const mainImage = item.querySelector(‘.product-image-link img’);
    const secondaryImage = item.querySelector(‘.hover-img img’);

    if (mainImage && secondaryImage) {
    mainImage.dataset.originalSrc = mainImage.src;
    mainImage.src = secondaryImage.src;
    mainImage.classList.add(‘zoom-animation’);
    }
    });

    item.addEventListener(‘touchend’, function () {
    const mainImage = item.querySelector(‘.product-image-link img’);

    if (mainImage && mainImage.dataset.originalSrc) {
    mainImage.src = mainImage.dataset.originalSrc;
    mainImage.classList.remove(‘zoom-animation’);
    }
    });
    });
    }

    // We call the function after the page is loaded
    document.addEventListener(‘DOMContentLoaded’, initProductHoverEffect);

    // We will call the function after loading the products dynamically using AJAX in the Woodmart theme
    jQuery(document).on(‘wood-images-loaded woodmart-ajax-success’, function() {
    initProductHoverEffect();
    });

    custom CSS for simple zoom animation
    /* Zoom animation for mobile products */
    .zoom-animation {
    transition: transform 1s ease;
    transform: scale(1.1); /* nastav zoom podľa potreby */
    }

    #604583

    Hello,

    You are Most Welcome.

    We are glad that you managed to solve the problem yourself. You are Great!!!

    Let us know if there’s anything else we can do for you! You can always reach us at any time. We are always here to help you.

    Have a wonderful day.

    Topic Closed.
    Best Regards.

Viewing 5 posts - 1 through 5 (of 5 total)