jQuery scroll animation 딜레이되는 현상
작성일 18-03-23 11:21
페이지 정보
작성자
본문
그냥 스크롤없이 한자리에서 새로고침하면 문제없는데 스크롤할 때 두세번째 이미지가 자꾸 바로 안나오고 딜레이 돼요ㅠㅠ
delay(0)줘도 안되고 그렇다고 스크롤탑을 줄이자니 이미지가 너무 일찍 나와서 안되고.. 어떻게해야 할까요
<div id="wrap">
<img src="img/sc_01.png" alt="">
<img src="img/sc_02.png" alt="">
<img src="img/sc_03.png" alt="">
</div>
#wrap img{
position:absolute;
}
#wrap img:first-child{
top:10%;
right:-60%;
}
#wrap img:nth-child(2){
top:38.5%;
left:-40%;
}
#wrap img:last-child{
top:65%;
right:-60%;
}
$(window).on('scroll',function(){
if($(window).scrollTop()>=2000){
$('#wrap img:first-child').animate({right:'30%'},'fast');
}
if($(window).scrollTop()>=1800){
$('#wrap img:nth-child(2)').animate({left:'20%'},'fast');
}
if($(window).scrollTop()>=1600){
$('#wrap img:last-child').animate({right:'30%'},'fast');
}
});
추천0
Re: scroll animation 딜레이되는 현상
페이지 정보
작성자
안녕하세요 디벨로드 입니다.^^

if($(window).scrollTop()>=2000 && check_animate1 == false){ // animate가 실행중이지 않을 경우만
check_animate1 = true; // if문이 실행되면 체크값을 바로 True로 변경해줍니다.$('#wrap img:first-child').animate({right:'30%'},'fast',function(){
check_animate1 = false; // animate가 끝나면 체크값을 다시 False로 변경해줍니다.
});
}
・ 관련링크 1개
댓글목록
등록된 댓글이 없습니다.