나는 원하는대로 작동하는 함수를 가지고 있습니다. 단지 너무 엉망이되어 부풀어 오르고 궁금해합니다. 아래 코드를 작성하는 더 좋은 방법이 있습니까?jQuery 콜백 최적화
function careerFlyIn(){
var distance = $('.row').offset().top,
$window = $(window);
var distance = distance - 200;
var flyInR = $('.path-description');
var flyInL = $('.path-title');
$window.scroll(function() {
if ($window.scrollTop() >= distance) {
$('.career-path .row:first-child').find(flyInL).animate({ 'left' : '0px' } ,400, 'easeOutBounce', function() {
$('.career-path .row:nth-child(2)').find(flyInL).animate({ 'left' : '0px' } ,400, 'easeOutBounce', function() {
$('.career-path .row:nth-child(3)').find(flyInL).animate({ 'left' : '0px' } ,400, 'easeOutBounce', function() {
$('.career-path .row:nth-child(4)').find(flyInL).animate({ 'left' : '0px' } ,400, 'easeOutBounce', function() {
$('.career-path .row:nth-child(5)').find(flyInL).animate({ 'left' : '0px' } ,400, 'easeOutBounce', function() { });
});
});
});
})
$('.career-path .row:first-child').find(flyInR).animate({ 'right' : '0px' } ,400, 'easeOutBounce', function() {
$('.career-path .row:nth-child(2)').find(flyInR).animate({ 'right' : '0px' } ,400, 'easeOutBounce', function() {
$('.career-path .row:nth-child(3)').find(flyInR).animate({ 'right' : '0px' } ,400, 'easeOutBounce', function() {
$('.career-path .row:nth-child(4)').find(flyInR).animate({ 'right' : '0px' } ,400, 'easeOutBounce', function() {
$('.career-path .row:nth-child(5)').find(flyInR).animate({ 'right' : '0px' } ,400, 'easeOutBounce', function() { });
});
});
});
})
}
});
};
을 테스트하지 왜 downvote? 이것은 작동하고 많은 비동기 문제에 유용한 기술입니다. –