开发者

java script 360 image rotating code slowing the rotation

I'm trying to create 360 degree image viewer like this using JavaScript.

But I couldn't achieve the effect for navigation link left, right, front and back (turning slowly). I need to hold loop iteration for a moment, I used the setInterval() function, and it didn't work for me. (This js is using 13 image to achieve.)

$(function() {
var leftImage =1 ;
var rightImage = 7;
var frontImage = 4;
var backImage = 10;

var arr1 = [];
for (var x=1; x<= 13; x++)
    arr1.push("images/"+x + ".jpg");

function showImage(img){
    $('#mousemove').attr('src', 'images/'+img+'.jpg');
}


function getCurrentImage(){
    var src = $("#mousemove").attr("src");
    var selected = src.split("/");
    var index = selected[1].split(".");
    var start = parseInt(index[0]);
    return start;

}

$(".pre").click(function(){ 
    var img = getCurrentImage() - 1;
    if (img==0) img=13;
        $('#mousemove').attr('src', 'images/'+img+'.开发者_运维知识库jpg');
});
$(".next").click(function(){
    var img = getCurrentImage()+ 1;
    if (img==13) img=1;
        $('#mousemove').attr('src', 'images/'+img+'.jpg');
});

$(".front").click(function(){ 
    var img = getCurrentImage();
    while( (img-1) != frontImage ){
        if (img==13) img=1;
          var reid = setInterval("showImage('+img+')", 5000);
        img++;
    }               
});
$(".left").click(function(){
    var img = getCurrentImage();
    while( (img-1) != leftImage ){
        if (img==13) img=1;
            showImage(img);
        img++;
    }   

});
$(".back").click(function(){
    var img = getCurrentImage();
    while( (img-1) != backImage ){
        if (img==13) img=1;
            showImage(img);
        img++;
    }   
});
$(".right").click(function(){ 
    var img = getCurrentImage();
    while( (img-1) != rightImage ){
        if(img==13) img=1;
            showImage(img);
        img++;
    }   
});

$("#mousemove").threesixty({images:arr1, method:'mousemove', 'cycle':2, direction:"backward"});
});


What does this parts of code means?

if (something) one=two;
        someanbother();

Did you mean for example this?

if (something) {
   one=two;
   someanbother();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜