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)
- This topic has 4 replies, 2 voices, and was last updated 6 months, 2 weeks ago by
Aizaz Imtiaz Awan.
-
AuthorPosts
-
October 12, 2024 at 12:13 am #604518
tmo.trnkaParticipantPlease 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.
October 12, 2024 at 12:05 pm #604562
Aizaz Imtiaz AwanKeymasterHello,
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
October 12, 2024 at 12:27 pm #604564
tmo.trnkaParticipantyeah that works of cource, but only on desktop devicer as i write here… not working on mobile devices
October 12, 2024 at 12:52 pm #604568
tmo.trnkaParticipantok 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 */
}October 12, 2024 at 2:00 pm #604583
Aizaz Imtiaz AwanKeymasterHello,
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. -
AuthorPosts
- You must be logged in to create new topics. Login / Register