1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | if(isScrolledIntoView(main05)){ $('#section05 .article h2').css({"animation-play-state":"running"}) if (!main05Status) { $('span.count').each(function(index) { var eachnum = $(this).text() $(this).prop('Counter',0); $(this).animate({ Counter: eachnum }, { interation: 1, duration: 3000, step: function(now) { $(this).text(parseInt(now)); } }); }); main05Status = true; } } | cs |
카운트 0부터 목표수치까지 올리는 애니메이션
마우스휠 이벤트 함수 바깥쪽에
main05Status = false; 선언하고
flag 값을 이용해서 한번만 움직이도록 해야함. flag값을 다른곳에 주어서 다시 화면으로 돌아왔을 때 동작하도록 할 수 있음.