자바스크립트 애니메이션 (ft.웹기능사시험 대비용)
시작하기 전에 JQ 멀쩡한지 점검


스와이퍼처럼 3겹으로 감싼다




여기까지 결과물


.aniitem{ display: flex;
flex-direction: column; // 가운데 정렬
align-items: center; // 가운데 정렬
justify-content: center;// 가운데 정렬
}

아이템을 left: -1200px로 이동시키는 것이 아닌, 걍 마진값 주는 건 상관없음.
<script>
$(document).ready(function(){
// 화면이 열리자마자 aniBox가 animate 한다
// CSS 스타일! margin-left:-1200px 주라!
$('.aniBox').animate({ 'marginLeft' : -1200 }, 400, function(){
// 만약 ({'left':-1200} 하려면?
})
})
</script>

① 이 객체(.aniBox) 맨 뒤에, div('.aniitem').첫번째 자식eq(0)을 appendTo밀어넣는다
→ eq( ) : 선택한 요소의 인덱스 번호에 해당하는 요소를 찾는다
② { 'marginLeft' : -1200 } 로 이동시킨 객체(.aniBox)를 원래 자리로 되돌려놓는다
(css 마진-left 값에 '0' 덮어씌우기)

즉, "화면이 열리자마자 .aniBox가 'marginLeft' : -1200' 위치로 animate,
4초간 아래 실행식을 실행한다"

+) .aniBox 맨 뒤에, 첫번째 자식 div를 안 보내면?

<script>
setInterval(function(){
$('.aniBox').animate({ 'marginLeft' : -1200 }, 400, function(){
$(this).find('div').eq(0).appendTo( $(this) );
$(this).css( 'margin-left', 0);
})
},3000)
</script>

