(41 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
$(function(){ | $(function(){ | ||
var pageNum = 0; | var pageNum = 0; | ||
− | + | var page = 15; | |
for (var i = 0; i < $('.runPage').length; i++) { | for (var i = 0; i < $('.runPage').length; i++) { | ||
$('.runPage').eq(i).css('z-index',2*page+1-2*i); | $('.runPage').eq(i).css('z-index',2*page+1-2*i); | ||
Line 9: | Line 9: | ||
$('.nextBtn').bind('click',function(){ | $('.nextBtn').bind('click',function(){ | ||
− | if ( pageNum <= | + | if ( pageNum <= page-1 ) { |
runNext(pageNum); | runNext(pageNum); | ||
pageNum++; | pageNum++; | ||
}; | }; | ||
− | console.log(pageNum); | + | console.log(pageNum); |
}); | }); | ||
Line 23: | Line 23: | ||
function zIndexNext(index,element){ | function zIndexNext(index,element){ | ||
if ( index >= 1 ) { | if ( index >= 1 ) { | ||
− | element.css('z-index',page+2*index); | + | element.css('z-index',page +10 +2*index); |
− | }; | + | }; |
setTimeout(function(){ | setTimeout(function(){ | ||
if (index==0) { | if (index==0) { | ||
Line 30: | Line 30: | ||
}; | }; | ||
element.children('div').css('z-index',page-1+2*index); | element.children('div').css('z-index',page-1+2*index); | ||
− | element.children('img').css('z-index',page+2*index); | + | element.children('img').css('z-index',page+2*index); |
},1000); | },1000); | ||
} | } | ||
$('.lastBtn').bind('click',function(){ | $('.lastBtn').bind('click',function(){ | ||
− | if ( pageNum >= 1 ) { | + | if ( pageNum >= 1 ) { |
pageNum--; | pageNum--; | ||
runLast(pageNum); | runLast(pageNum); | ||
}; | }; | ||
− | console.log(pageNum); | + | console.log(pageNum); |
}); | }); | ||
Line 54: | Line 54: | ||
element.css('z-index',2*page+1-2*index); | element.css('z-index',2*page+1-2*index); | ||
element.children('div').css('z-index',2*page+1-2*index); | element.children('div').css('z-index',2*page+1-2*index); | ||
− | element.children('img').css('z-index',2*page-2*index); | + | element.children('img').css('z-index',2*page-2*index); |
},1000); | },1000); | ||
} | } | ||
}); | }); |
Latest revision as of 15:09, 20 October 2019
$(function(){ var pageNum = 0;
var page = 15;
for (var i = 0; i < $('.runPage').length; i++) { $('.runPage').eq(i).css('z-index',2*page+1-2*i); $('.runPage').eq(i).children('div').css('z-index',2*page+1-2*i); $('.runPage').eq(i).children('img').css('z-index',2*page-2*i); };
$('.nextBtn').bind('click',function(){ if ( pageNum <= page-1 ) { runNext(pageNum); pageNum++; }; console.log(pageNum); });
function runNext(index){ $('.runPage').eq(index).addClass('runClass'); zIndexNext(index,$('.runPage').eq(index)); }
function zIndexNext(index,element){ if ( index >= 1 ) { element.css('z-index',page +10 +2*index); }; setTimeout(function(){ if (index==0) { element.css('z-index',page+2*index); }; element.children('div').css('z-index',page-1+2*index); element.children('img').css('z-index',page+2*index); },1000); }
$('.lastBtn').bind('click',function(){ if ( pageNum >= 1 ) { pageNum--; runLast(pageNum); }; console.log(pageNum); });
function runLast(index){ $('.runPage').eq(index).removeClass('runClass'); zIndexLast(index,$('.runPage').eq(index)); }
function zIndexLast(index,element){ if (index == 0) { element.css('z-index',2*page+1-2*index); }; setTimeout(function(){ element.css('z-index',2*page+1-2*index); element.children('div').css('z-index',2*page+1-2*index); element.children('img').css('z-index',2*page-2*index); },1000); } });