程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> html5-急求教!請JS或H5高手幫忙看個代碼,代碼中哪段是控制(圖片)最大播放數量的?

html5-急求教!請JS或H5高手幫忙看個代碼,代碼中哪段是控制(圖片)最大播放數量的?

編輯:編程綜合問答
急求教!請JS或H5高手幫忙看個代碼,代碼中哪段是控制(圖片)最大播放數量的?

我是新手,看不太明白,求教。。。
目前的代碼是有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);}這條控制最小數

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved