Description:
Enhance the Product Display Page (PDP) of a website by adding a 360-degree image view feature, allowing customers to view products from all angles for a more immersive and interactive shopping experience.
Solution:
I checked the possibilities to enhance the Product Display Page (PDP) of a website by adding a 360-degree image view feature. For that first we want a 360-degree images and video. After that we need to create an extension for the Shopping page. Here we need to extend the module used for image Gallery. There we call the item field id as per requirement. The corresponding 360-degree interactive html gallery and video will show in the image gallery. Then in item record we need to update the 360-degree image and video. After done this all-things website was allowing customers to view products from all angles for a more immersive and interactive shopping experience.
var num = 36; // the total number of images
// Preload all the images into hidden div
for (var i=1 ; i<=num ; i++) {
var img = document.createElement('img');
img.src = 'http://woosterwebdesign.com/experiments/images/car_slides/car_('+i+').jpg';
document.getElementById('preload-imgs').appendChild(img);
}
// Control swipes using jquery.touchSwipe.min.js
// http://labs.rampinteractive.co.uk/touchSwipe/
var swipeOptions=
{
triggerOnTouchEnd : true,
swipeStatus : swipeStatus,
allowPageScroll:"vertical",
threshold:75
}
$(function()
{
imgs = $(".img-container"); // the element that will be swipeable
imgs.swipe( swipeOptions );
});
function swipeStatus(event, phase, direction, distance) {
var duration = 0;
if(direction == "left") {
changeImg(distance);
}
else if (direction == "right") {
changeImgR(-distance);
}
}
function changeImg (imgNum) {
// divide by 8 (or any number) to spread
// it out so it doesn't load new img
// every single px of swipe distance
imgNum = Math.floor(imgNum/8);
if (imgNum < 1) {
imgNum += num;
}
if (imgNum > num) {
imgNum -= num;
}
// change the image src
document.getElementById("myImg").src="http://woosterwebdesign.com/experiments/images/car_slides/car_("+imgNum+").jpg";
}
function changeImgR (imgNum) {
// divide by 8 (or any number) to spread
// it out so it doesn't load new img
// every single px of swipe distance
imgNum = Math.floor(imgNum/8);
var num2 = -Math.abs(num);
if (imgNum > num2) {
imgNum += num;
}
if (imgNum <= num2) {
imgNum += num*2;
}
// change the image src
document.getElementById("myImg").src="http://woosterwebdesign.com/experiments/images/car_slides/car_("+imgNum+").jpg";
}
})