지점에 도달하면 브라우저가 애니메이션을 동시에 재생합니다. 그건 내가 원하는 것이 아니야. 브라우저는 모든 애니메이션을 분리하여 재생해야합니다.jQuery, 요소가 화면에있을 때 애니메이션 재생 방법
이 내 jQuery 코드입니다 :
function initScrollAnimation(){
$('.slideLeft').each(function(i){
var bottom_of_object = $(this).position().top + $(this).outerHeight() + $(window).height() - 500;
var bottom_of_window = $(window).scrollTop() + $(window).height();
if(bottom_of_window > bottom_of_object){
$(".slideLeft").addClass('active');
}; //else {
//$(".slideLeft").removeClass('active');
//};
});
$('.slideRight').each(function(i){
var bottom_of_object = $(this).position().top + $(this).outerHeight() + $(window).height() - 500;
var bottom_of_window = $(window).scrollTop() + $(window).height();
if(bottom_of_window > bottom_of_object){
$(".slideRight").addClass('active');
}; //else {
//$(".slideLeft").removeClass('active');
//};
});
}
그리고 이것은 CSS 코드
.slideLeft{
margin-left:-25%;
}
.slideRight{
margin-right:-25%;
}
.slideLeft.active{
margin-left: 0%;
transition: all 0.5s ease-in;
}
.slideRight.active{
margin-right: 0%;
transition: all 0.5s ease-in;
}
[웨이 포인트] (https://github.com/imakewebthings/waypoints) 라이브러리를 사용하여 요소가 도달하면 – Mivaweb
의 "도달 지점에 도달했을 때"할 수 있습니다. 어떤 시점에 도달 했습니까? –