이것은 stackoverflow, hello everyone의 내 첫 번째 게시물입니다!jQuery 선택기 samba
jQuery 애니메이션으로의 첫 번째 벤처는 두 개의 div, 즉 상반기와 하반기에 이미지 집합을 가지고 플립형 전환으로 플립 다운 전환과 함께 고대 시계를 회전시키는 것입니다. 다운 번호.
애니메이션이 다운되었지만 문제가 페이지에서 동시에 애니메이션을 생성하는 중 하나 이상을 가지고 있습니다. 내 문제는 jQuery 선택기의 범위를 이해하지 못하는 데서 비롯된다. 이 내가 설명 이미지 세트에서 실행되는
$(document).ready(function(){
flippers($('.flipper'));
});
function flippers(divs){
divs.each(function(i){
$(".top_container img").each(function (j){
$(this).attr("id",i+"t"+j);
});
$(".bottom_container img").each(function(j){
$(this).attr("id",i+"b"+j);
});
});
var flip_wait = 3600;
setTimeout("flippers_start("+flip_wait+")",flip_wait);
}
function flippers_start(time,flipper){
var curr_top = '#' + $('.top_container img:visible').attr('id');
var curr_bottom = '#' + $('.bottom_container img:visible').attr('id');
if(($('.top_container img').size() - 1) <= curr_top[3]){
var next_top = curr_top.substring(0,3) + 0;
var next_bottom = curr_bottom.substring(0,3) + 0;
}
else{
var next_top = curr_top.substring(0,3) + (parseInt(curr_top[3]) + 1);
var next_bottom = curr_bottom.substring(0,3) + (parseInt(curr_bottom[3]) + 1);
}
var height = $(curr_top).height();
var width = $(curr_top).width();
flip(height,width,curr_top,curr_bottom,next_top,next_bottom);
setTimeout("flippers_start("+time+")",time);
}
function flip(height,width,fromtop,frombottom,totop,tobottom){
var fliptime = 250;
$(frombottom).css("z-index","1");
$(tobottom).css("z-index","2");
$(fromtop).css("z-index","2");
$(totop).css("z-index","1");
$(tobottom).css("height","1px").show();
$(totop).show();
$(fromtop).stop().animate({height:'0px',width:''+width+'px',marginTop:''+height+'px'},{duration:fliptime});
window.setTimeout(function() {
$(tobottom).stop().animate({height:''+height+'px',width:''+width+'px',marginBottom:'0px',opacity:'1'},{duration:fliptime});
},fliptime-40);
$(frombottom).slideUp();
window.setTimeout(function(){
$(fromtop).height(height).hide().css("margin-top","0px");
},fliptime*2);
}
, 그것이 내가 그것을 기대 다만 방법을 작동
<div class="flipper">
<div class="top_container">
<img src="images/pink_floyd_img/dark1.jpg" class="top first" />
<img src="images/pink_floyd_img/wall1.jpg" class="top second hidden" />
<img src="images/pink_floyd_img/wish1.jpg" class="top third hidden" />
</div>
<div class="bottom_container">
<img src="images/pink_floyd_img/dark2.jpg" class="bottom first" />
<img src="images/pink_floyd_img/wall2.jpg" class="bottom second hidden" />
<img src="images/pink_floyd_img/wish2.jpg" class="bottom third hidden" />
</div>
</div>
. 그러나 "플리퍼"div를 복제하면 애니메이션이 첫 번째 세트에서 먼저 실행 된 다음 두 번째 세트에서 실행됩니다.
나는 애니메이션을 적용 할 각 이미지를 선택하는 방식과 관련이 있다는 것을 알고 있습니다. 그것이 일어날 때, 그러나 나는 정말로 내가하는 일을 어떻게 해야할지 모르겠다.
궁극적 인 목표는 div와 이미지를 적절한 클래스로 마크 업하고 애니메이션을 실행하기 위해 동적으로 설정하고 애니메이션을 동시에 시작할 수있게하는 것입니다. 각각의 div에 대해 별도의 호출이 있어도 (이렇게되면 결국 모든 것이 동시에 전환되지 않습니다.)
감사합니다.
나는 잘 모르겠지만 분명히하고 실제로 질문에 충분한 정보를 제공하고, "plz send me teh codez"를 가져 오지 않았습니다. –
내가 아는 한 한 번에 한 항목 만 한 페이지에 애니메이션을 적용 할 수 있으며, 현재 애니메이션이 멈 추면 다른 모든 항목은 자동으로 대기열에 놓이고 실행됩니다. – Jojo