티스토리 뷰

GSAP

[GSAP] Stagger

Stagger

애니메이션을 순차적으로 적용합니다.


Stagger

애니메이션을 순차적으로 적용합니다.

문법(Syntax)

TweenMax.to("target", duration, vars);

이동하기

애니메이션을 순차적으로 적용합니다.

Sample1
box
box
box
box
JQUERY
//jQuery
GSAP
$(".start").on("click",function(){
    TweenMax.staggerTo([".box1",".box2",".box3",".box4"] ,1, {left:"90%", scale:0.2, ease:Power3.easeOut},0.25);
});

$(".choice .reset").on("click",function(){
    TweenMax.to([".box1, .box2, .box3, .box4"], 0, { left: "0" });
});
JAVASCRIPT
const startBtn = document.querySelector('.start');
const resetBtn = document.querySelector('.reset');

startBtn.addEventListener('click', moveStart);
resetBtn.addEventListener('click', moveReset);

function moveStart(){
    TweenMax.staggerTo([".box1",".box2",".box3",".box4"] ,1, {left:"90%", scale:0.2, ease:Power3.easeOut},0.25);
}
function moveReset(){
    TweenMax.to([".box1, .box2, .box3, .box4"], 0, { left: "0" });
}
TOTAL
<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <title>GSAP Stagger</title>
    <style>
        .box_wrap {width: 100%;}
        .box_wrap div {
            display: block; width: 60px; height: 60px; line-height: 65px; text-align: center; 
            border-radius: 50%; overflow: hidden; position: relative; font-size: 12px; color: #fff; margin: 4px;
            background-image: linear-gradient(45deg, #fbc2eb 0%, #a6c1ee 100%);
        }
    </style>
</head>
<body>
    <div class="box_wrap">
        <div class="box1">box</div>
        <div class="box2">box</div>
        <div class="box3">box</div>
        <div class="box4">box</div>
    </div>

    <div class="choice">
        <a href="#" class="reset">리셋</a>
        <a href="#" class="start">클릭하면 이동합니다.</a>
    </div>
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.1.2/TweenMax.min.js"></script>
    <script>
        $(".choice a").on("click",function(e){
            e.preventDefault();
        });

        //jquery

        //gsap
        // $(".start").on("click",function(){
        //     TweenMax.staggerTo([".box1",".box2",".box3",".box4"] ,1, {left:"90%", scale:0.2, ease:Power3.easeOut},0.25);
        // });

        // $(".choice .reset").on("click",function(){
        //     TweenMax.to([".box1, .box2, .box3, .box4"], 0, { left: "0", scale:1  });
        // }); 
    
        //javascript
        const startBtn = document.querySelector('.start');
        const resetBtn = document.querySelector('.reset');

        startBtn.addEventListener('click', moveStart);
        resetBtn.addEventListener('click', moveReset);
        
        function moveStart(){
            TweenMax.staggerTo([".box1",".box2",".box3",".box4"] ,1, {left:"90%", scale:0.2, ease:Power3.easeOut},0.25);
        }
        function moveReset(){
            TweenMax.to([".box1, .box2, .box3, .box4"], 0, { left: "0", scale:1  });
        }
    </script>
</body>
</html>

공유하기(Share) 더보기

  • 네이버 블러그 공유하기
  • 페이스북 공유하기
  • 트위터 공유하기
  • 트위터 공유하기
  • 트위터 공유하기

공감하기(Like) 더보기

UP NEXT : Ads by Google

질문하기(Questions)
댓글쓰기 폼