很多购物网站现在都支持360实物全景图像,可以360度任意选择查看样品,这样对购买者来说是一个很好的消费体验,网上有很多这样的插件都是基于jQuery实现的有收费的也有免费的,其实很好用的一个叫3deye.js的插件。该插件支持桌面与移动终端iOS与Android, 它的demo程序:http://huoche.7234.cn/images/jb51/gq3ontddan5.jpg"; } else { images[i] = new Image(); images[i].src = i + ".jpg"; } } ctx = canvas.getContext("2d"); // mouse event canvas.addEventListener("mousedown", doMouseDown, false); canvas.addEventListener('mousemove', doMouseMove, false); canvas.addEventListener('mouseup', doMouseUp, false); // loaded(); // frame = 1 frame = 1; images[frame].onload = function() { redraw(); bar.style.display = 'none'; } } function doMouseDown(event) { var x = event.pageX; var y = event.pageY; var canvas = event.target; var loc = getPointOnCanvas(canvas, x, y); console.log("mouse down at point( x:" + loc.x + ", y:" + loc.y + ")"); startedX = loc.x; started = true; } function doMouseMove(event) { var x = event.pageX; var y = event.pageY; var canvas = event.target; var loc = getPointOnCanvas(canvas, x, y); if (started) { var count = Math.floor(Math.abs((startedX - loc.x)/30)); var frameIndex = Math.floor((startedX - loc.x)/30); while(count > 0) { console.log("frameIndex = " + frameIndex); count--; if(frameIndex > 0) { frameIndex--; frame++; } else if(frameIndex < 0) { frameIndex++; frame--; } else if(frameIndex == 0) { break; } if(frame >= 24) { frame = 1; } if(frame <= 0) { frame = 23; } redraw(); } } } function doMouseUp(event) { console.log("mouse up now"); if (started) { doMouseMove(event); startedX = -1; started = false; } } function getPointOnCanvas(canvas, x, y) { var bbox = canvas.getBoundingClientRect(); return { x: x - bbox.left * (canvas.width / bbox.width), y: y - bbox.top * (canvas.height / bbox.height) }; } function loaded() { setTimeout( update, 1000/8); } function redraw() { // var imageObj = document.createElement("img"); // var imageObj = new Image(); var imageObj = images[frame]; ctx.clearRect(0, 0, width, height) ctx.drawImage(imageObj, 0, 0, width, height); } function update() { redraw(); frame++; if (frame >= 23) frame = 1; setTimeout( update, 1000/8); } </script> </head> <body> <progress id="loadProgressBar" value="0" max="23"></progress> <canvas id="fullview_canvas"></canvas> <button onclick="loaded()">Auto Play</button> </body> </html>
Demo演示文件下载地址-> fullview_jb51.rar