我是新手,看不太明白,求教。。。
目前的代碼是有10張圖片順序播放,但是我希望只播放3張,也就是最大播放數量控制在3以內。
非常感謝!!!
(function(){
var now = { row:1, col:1 }, last = { row:0, col:0};
const towards = { up:1, right:2, down:3, left:4};
var isAnimating = false;
s=window.innerHeight/500;
ss=250*(1-s);
$('.wrap').css('-webkit-transform','scale('+s+','+s+') translate(0px,-'+ss+'px)');
document.addEventListener('touchmove',function(event){
event.preventDefault(); },false);
$(document).swipeUp(function(){
if (isAnimating) return;
last.row = now.row;
last.col = now.col;
if (last.row != 10) { now.row = last.row+1; now.col = 1; pageMove(towards.up);}
})
$(document).swipeDown(function(){
if (isAnimating) return;
last.row = now.row;
last.col = now.col;
if (last.row!=1) { now.row = last.row-1; now.col = 1; pageMove(towards.down);}
})
//$(document).swipeLeft(function(){
// if (isAnimating) return;
// last.row = now.row;
// last.col = now.col;
// if (last.row>1 && last.row
//})
//
//$(document).swipeRight(function(){
// if (isAnimating) return;
// last.row = now.row;
// last.col = now.col;
// if (last.row>1 && last.row<5 && last.col==2) { now.row = last.row; now.col = 1; pageMove(towards.right);}
//})
function pageMove(tw){
var lastPage = ".page-"+last.row+"-"+last.col,
nowPage = ".page-"+now.row+"-"+now.col;
switch(tw) {
case towards.up:
outClass = 'pt-page-moveToTop';
inClass = 'pt-page-moveFromBottom';
break;
case towards.right:
outClass = 'pt-page-moveToRight';
inClass = 'pt-page-moveFromLeft';
break;
case towards.down:
outClass = 'pt-page-moveToBottom';
inClass = 'pt-page-moveFromTop';
break;
case towards.left:
outClass = 'pt-page-moveToLeft';
inClass = 'pt-page-moveFromRight';
break;
}
isAnimating = true;
$(nowPage).removeClass("hide");
$(lastPage).addClass(outClass);
$(nowPage).addClass(inClass);
setTimeout(function(){
$(lastPage).removeClass('page-current');
$(lastPage).removeClass(outClass);
$(lastPage).addClass("hide");
$(lastPage).find("img").addClass("hide");
$(nowPage).addClass('page-current');
$(nowPage).removeClass(inClass);
$(nowPage).find("img").removeClass("hide");
isAnimating = false;
},600);
}
})();
if (last.row != 10) { now.row = last.row+1; now.col = 1; pageMove(towards.up);} 這條控制最大數
if (last.row!=1) { now.row = last.row-1; now.col = 1; pageMove(towards.down);}這條控制最小數