[GSAP] 개념/메서드 정리

2024. 6. 27. 00:48·GSAP
728x90

 GASP :

스크립트 애니메이션을 위한 도구 모음

 

 

설치

 <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"></script>

 

 

Installation | GSAP | Docs & Learning

GSAP is "framework agnostic", this means it can be used in React, Webflow, Wordpress, or any other JS/Web frameworks. The core GSAP file and all the plugins are just Javascript files.

gsap.com

 

기본문법

gsap.to()

타겟 엘리먼트의 끝 값을 지정하는기본 메서드(시작 후 종료되는 값을 지정)

 

애니메이션을 제작하기 위해 2가지 요소가 필요하다.

- targets : 객체, 객체의 배열, .class

- vars : 속성 ex) duration: 1, opacity: 0, stagger: 0.05

gsap.to(".test", {opacity:0, xPercent: 100, stagger: 0.05})

 

 

gsap.from()

to() 메서드와 반대로 시작점을 지정할 수 있다.

*opacity : 0으로 설정하여 글자가 안 보여지는 상태 -> 보여지도록 효과

gsap.from(text.chars, {
        scrollTrigger: {
            trigger: "#section_01 .text_box",
            start: 'top 70%',
            end: 'top top',
            scrub: false,
            /* markers: true, */
            toggleActions: 'play play reverse reverse'
        },
        //*모션효과
        opacity: 0,
        stagger: 0.08,
        duration: 0.5,
    }

 

 

gsap.fromTo()

타겟 엘리먼트의 시작과 끝을 함께 지정해주는 메서드

*이미지 안보여지는 상태 -> 0.5초 동안 점차 보여지도록(power04.out)한다. 

.fromTo(".wrap .main_img", { opacity: 0 }, {opacity: 1, ease: "power04.out", duration: 0.5});

 

 

gsap.set()

타겟 엘리먼트의 즉시 설정, 초기값 설정 (set 초기값 먼저 지정 후 to메서드 사용)

*아이콘 초기 위치값 설정 -> 트리거발생시 지정 위치로 이동

.set(".wrap .man_icon:nth-of-type(1)", { left: "50%", top: "38%" })
.set(".wrap .man_icon:nth-of-type(2)", { right: "35%", top: "20%" })
.set(".wrap .man_icon:nth-of-type(3)", { right: "25%", top: "30%" })
(...)
.to(".wrap .man_icon:nth-of-type(1)", { left: "20%", top: "20%" })
.to(".wrap .man_icon:nth-of-type(2)", { right: "20%", top: "0%" })
.to(".wrap .man_icon:nth-of-type(3)", { right: "10%", top: "20%" })

 

 

gsap.timeline()

애니메이션 그룹을 전체적으로 제어, 모드 모듈화, 콜백문법 사용가능

 

단축코드

*top, left 대신 x 와 y (transform)를 사용하는것이 좋습니다.

*속성표기법 : cameCase ex) fontSize, backgroundColor

GSAP CSS
x : 100 transform : translateX (100px)
y : 100 transform : translateY (100px)
rotation : 360 transform : rotate(360deg)
rotationX : 360 transform : rotateX(360deg)
rotationY : 360 transform : rotateY(360deg)
skewX : 45 transform : skewX (45deg)
scale : 2 transform : scale (2, 2)
xPercent : -50 transform : translateX(-50%)
yPercent : -50 transform : translateY(-50%)

 

 

 

 

 

 


플러그인

Split-Tpye

텍스트를 개별 글자, 단어, 줄 단위로 쉽게 분리하여 애니메이션 효과 등을 적용할 수 있게 해주는 JavaScript 플러그인

<!-- Minified UMD bundle -->
<script src="https://unpkg.com/split-type"></script>

 

*작업소스

<section id="section_02">
	<h2 class="my_Type">글자들이 서서히 내려옵니다.</h2>
	<p class="me_Type">글자들이 서서히 올라옵니다.</p>
</section>
        
const myType = document.querySelectorAll(".my_Type");

          myType.forEach((char, e) => {
            const text = new SplitType(char, {type: "chars"}); // 글자 쪼개기

            gsap.fromTo(text.chars, {
                y:-100,
            },{
                y:0,
                duration:0.5,
                stagger:0.05,
                scrollTrigger:{
                    trigger: char,
                    start:"top 60%",
                    end: "top 20%",
                    markers:true,
                    scrub:false,
                    toggleActions: "play play reverse reverse",
                }
            })
          });

 

[CSS] Clip-Path 

대상이 되는 엘리먼트에 사용하여 circle, ellipsis, polygon(다각형) 등의 원하는 영역만 가위로 자른 것처럼 보여줄 수 있습니다. 

clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
 

Clippy — CSS clip-path maker

About Clip Paths The clip-path property allows you to make complex shapes in CSS by clipping an element to a basic shape (circle, ellipse, polygon, or inset), or to an SVG source. CSS Animations and transitions are possible with two or more clip-path shape

bennettfeely.com

 


 

MorphSVGPlugin: 복잡한 SVG Paths를 부드럽게 모핑

 

MorphSVG | GSAP | Docs & Learning

Description

gsap.com

DrawSVGPlugin: SVG Strokes의 길이와 위치를 애니메이션

 

DrawSVG | GSAP | Docs & Learning

Description

gsap.com

MotionPathPlugin: Path를 따라 모든 요소에 애니메이션을 적용

 

MotionPath | GSAP | Docs & Learning

Animate any object along a path (or even through arbitrary property values). The motionPath can be defined as any of the following:

gsap.com

 

 

 

 

728x90

'GSAP' 카테고리의 다른 글

[GSAP] barba.js 개념정리/문법  (0) 2024.07.22
[GSAP] 상하좌우 슬라이드(PIN)  (0) 2024.07.05
'GSAP' 카테고리의 다른 글
  • [GSAP] barba.js 개념정리/문법
  • [GSAP] 상하좌우 슬라이드(PIN)
PUSH → MERGE → DEPLOY
PUSH → MERGE → DEPLOY
데이터 흐름과 운영 자동화를 설계하는 백엔드 개발자
  • PUSH → MERGE → DEPLOY
    Coding Dongin
    PUSH → MERGE → DEPLOY
  • 전체
    오늘
    어제
    • MEUN
      • 코테(Solved.ac + Programmers)
      • BootCamp(JAVA)
      • JAVA
      • SpringBoot
      • JavaScript
      • JSP
      • DB(SQL)
      • React
      • HTML_CSS
      • jQuery
      • SCSS
      • GSAP
      • 설치 + 꿀팁
      • 정보처리기사 오답노트
      • 정보처리기사 기출문제
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

    • GIT
  • 공지사항

  • 인기 글

  • 태그

    Level2
    피보나치
    백엔드개발자
    코딩테스트
    문자열
    실기
    시뮬레이션
    dp
    정렬
    프로그래머스
    정보처리기사 실기 기출문제
    백준
    수학
    level1
    자료구조
    level0
    완전탐색
    solved.ac
    자바
    구현
    기출문제
    springboot
    브루트포스
    알고리즘
    정처기실기
    정처기오답노트
    정처기
    정보처리기사
    java
    배열
  • 최근 댓글

  • 최근 글

  • 250x250
  • hELLO· Designed By정상우.v4.10.4
PUSH → MERGE → DEPLOY
[GSAP] 개념/메서드 정리
상단으로

티스토리툴바