How to Implement 360-degree panoramic photo problem Summarization in javascript _ javascript skills

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.