This article provides a detailed summary of how javascript achieves 360-degree Panoramic photos. If you are interested, you can refer to this article to share the detailed steps for creating 360-degree Panoramic photos, pay attention to the following issues:
1. How can I load images faster? --- Make sure that the image hiding performance is higher than the image switching performance, and run in IE9, the image loading problem may occur.
2. How to make the image rotate at a certain speed
3. If x is negative or negative
The Code is as follows:
Untitled documentScript window. onload = function () {var oImg = document. getElementById ('img1'); // the first image var aImg = document. getElementsByTagName ('img '); var lastimage = oImg; var x = 0; // drag a point with the mouse to change src var speed = 0; var lastx = 0; var timer = null; var temp = 0; for (I = 0; I <77; I ++) {var oNewImage = document. createElement ('img '); oNewImage. src = 'img/miaov ('{ I }'{.jpg '; oNewImage. style. display = 'none'; document. body. appendChild (oNewImage); // hide 77 images first} document. onmousedown = function (ev) {clearInterval (timer); var oEvent = ev | event; var disx = oEvent. clientX-x; document. onmousemove = function (ev) {var oEvent = ev | event; x = oEvent. clientX-disx; setMove (); speed = x-lastx; // record the first and second velocity lastx = x; return false;} document. onmouseup = function () {document. onmousemove = null; document. onmouseup = null; timer = setInterval (function () {x + = speed; setMove (); document. title = speed ;}, 30) ;}function setMove () {if (speed> 0) {speed --;} else if (speed = 0) {clearInterval (timer) ;}else {speed ++;} temp =-x; // set temp to the global variable if (temp> 0) {temp =-x % 77;} else {temp =-x + (-Math. floor (-x/77) * 77);} // oImg. src = 'img/miaov ('{temp}'{.jpg '; // use a pair of single quotes outside the image. // alert (aImg. length); lastimage. style. display = 'none'; // first change the last image to none (the first image is displayed when the mouse is not moved at the beginning) aImg [temp]. style. display = 'block'; // when the page is opened, the first image lastimage = aImg [temp]; document is displayed by default. title = temp;} return false;} script
The above is all the content of this article, hoping to help you learn.