iotron/gsap-cookbook

gsap-scroll

Production recipes for scroll-based GSAP animations.

소스 보기

사용 방법

  1. 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
  2. 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
  3. 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/iotron/gsap-cookbook --skill gsap-scroll

시작 전 확인

  • 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
  • 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 Skill 문서

원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.

GSAP Scroll — ScrollTrigger Patterns

Flow: gsap-setup → gsap-animate → gsap-scroll → gsap-optimise → gsap-test Cross-reference gsap-animate for context/cleanup, gsap-optimise for batch/scrub tuning.
Companion: For ScrollTrigger API reference, invoke gsap-scrolltrigger. This skill covers scroll animation recipes only. Requires: greensock/gsap-skills

1. Basic Scroll Reveal

js
ctx = gsap.context(() => {
  const els = gsap.utils.toArray('.reveal', sectionRef.value)
  gsap.set(els, { y: 28, autoAlpha: 0 })

  els.forEach((el) => {
    gsap.to(el, {
      y: 0, autoAlpha: 1, duration: 0.8, ease: 'power2.out', force3D: true,
      scrollTrigger: {
        trigger: el, start: 'top 88%',
        toggleActions: 'play none none reverse',
        invalidateOnRefresh: true,
      },
    })
  })
}, sectionRef.value)
  • autoAlpha not opacity — sets visibility: hidden at 0
  • toggleActions: 'play none none reverse' — plays on enter, reverses on leave-back

2. ScrollTrigger.batch() — Masonry/Grid Reveal

js
ctx = gsap.context(() => {
  const cards = gsap.utils.toArray('.masonry-card')
  gsap.set(cards, { y: 60, autoAlpha: 0, rotation: () => gsap.utils.random(-3, 3) })

  const ENTER = { y: 0, autoAlpha: 1, rotation: 0, stagger: 0.08, duration: 0.8,
                  ease: 'power3.out', force3D: true, overwrite: 'auto' }
  const EXIT_UP   = { y: -20, autoAlpha: 0, duration: 0.4, ease: 'power2.in', overwrite: 'auto' }
  const EXIT_DOWN = { y: 60,  autoAlpha: 0, duration: 0.4, ease: 'power2.in', overwrite: 'auto' }

  ScrollTrigger.batch(cards, {
    onEnter:     (batch) => gsap.to(batch, ENTER),
    onLeave:     (batch) => gsap.to(batch, EXIT_UP),
    onEnterBack: (batch) => gsap.to(batch, ENTER),
    onLeaveBack: (batch) => gsap.to(batch, EXIT_DOWN),
    start: 'top 85%', end: 'bottom 15%',
  })
}, sectionRef.value)
  • overwrite: 'auto' prevents conflicting tweens on fast scroll
  • Functional rotation re-evaluates per element for organic randomness

3. Parallax Layers

html
<div class="parallax-layer" data-speed="0.2"><!-- slow --></div>
<div class="parallax-layer" data-speed="0.6"><!-- fast --></div>
js
ctx = gsap.context(() => {
  gsap.utils.toArray('.parallax-layer', sectionRef.value).forEach((layer) => {
    const speed = parseFloat(layer.dataset.speed) || 0.5
    gsap.to(layer, {
      yPercent: -50 * speed, ease: 'none', force3D: true,
      scrollTrigger: {
        trigger: sectionRef.value, start: 'top bottom', end: 'bottom top', scrub: 0.5, invalidateOnRefresh: true,
      },
    })
  })
}, sectionRef.value)
  • yPercent not y — percentage-based, scales with element size
  • scrub: 0.5 — smoother than scrub: true, 0.5s catch-up

4. Refresh Patterns

js
await nextTick(); ScrollTrigger.refresh()                              // v-if toggles
img.addEventListener('load', () => ScrollTrigger.refresh())            // lazy images
document.fonts.ready.then(() => ScrollTrigger.refresh())               // font swap
ScrollTrigger.config({ ignoreMobileResize: true })                     // address bar

Advanced Patterns

See references/scroll-patterns.md for:

  • Stacking Cards — CSS sticky + scrubbed two-phase timeline with will-change lifecycle
  • Scrubbed Timeline — progress bar, bouncing dots, alternating card reveals
  • Elastic Type Assembly — pin + scrub three-phase scatter/assemble/scatter
  • Service Section Switching — ScrollTrigger.create() with activate/deactivate callbacks
  • Velocity Skew — skewY transforms driven by ScrollTrigger.getVelocity() + gsap.quickSetter
  • Infinite Looped Panels — pinSpacing: false stacking with seamless scroll boundary looping
  • Directionally Aware Header — show/hide fixed header based on scroll direction
  • Pinned Panels with Overscroll — slide-based pinning with fake-scroll for tall panels + scale/fade exit
  • Image Mask On Scroll — before/after image reveal using counter-translating containers
  • Lateral Pin Indicator — pinned section with side nav indicator + crossfading slide content
  • Horizontal Scrolling Gallery — horizontal scroll via pin + scrub with xPercent translation

Rules

  1. Wrap all ScrollTrigger tweens in gsap.context() scoped to a ref
  2. Use autoAlpha not opacity for reveals
  3. Include invalidateOnRefresh: true when animating positional values
  4. Use overwrite: 'auto' or true when elements can be re-triggered
  5. Manage will-change lifecycle in ST callbacks (set on enter, release on leave)
  6. Call ScrollTrigger.refresh() after DOM changes that affect document height
  7. Prefer scrub: 0.5 over scrub: true for smoother motion
같은 저장소의 Skills

더 많은 Skills

모든 Skills
iotron
커뮤니티

gsap-cursor

Production recipes for cursor and pointer-driven GSAP animations. Companion to official gsap-core and gsap-performance skills (API reference). Triggers: cursor follower, cursor effect, mouse follower, magnetic button, spotlight cursor, cursor trail, particle trail, spring cursor, elastic cursor, pointer animation, custom cursor, cursor glow, clipPath cursor, quickTo cursor, image preview hover, perspective tilt, 3D tilt cursor. Non-triggers: Not for hover/tilt card effects (use gsap-interact), n

1시간 설치 수
1
GitHub Stars
9
업데이트
3월 24일
iotron
커뮤니티

gsap-interact

Production recipes for mouse-driven interactive GSAP animations. Companion to official gsap-core and gsap-performance skills (API reference). Triggers: GSAP mouse, mousemove animation, tilt card, 3D tilt, quickTo, quickSetter, hover animation, interactive GSAP, parallax hover, drag interaction, Draggable, liveSnap, mouse-driven animation, dock effect, macOS dock, magnification, proximity scale, dock magnify. Non-triggers: Not for scroll-driven animation (use gsap-scroll), text effects (use gsap-

1시간 설치 수
1
GitHub Stars
9
업데이트
3월 24일
iotron
커뮤니티

gsap-showcase

Production-grade premium animation compositions from official GSAP showcases. Complete multi-plugin references for building beautiful, polished animations. Companion to official gsap-core, gsap-plugins, gsap-timeline skills (API reference). Triggers: premium animation, showcase, production animation, beautiful animation, hero animation, page transition, loading animation, immersive scroll, complete animation, polished animation, animation composition, multi-plugin animation. Non-triggers: Not fo

1시간 설치 수
1
GitHub Stars
9
업데이트
3월 24일
iotron
커뮤니티

gsap-svg

Production recipes for GSAP SVG animations. Companion to official gsap-plugins skill (API reference). Triggers: SVG animation, GSAP SVG, path drawing, strokeDashoffset, DrawSVG, drawSVG, SVG morph, MorphSVGPlugin, circuit tree, circuit board, CTAHud, HUD animation, pulse ring, scallop wave, SVG stagger, SVG fill, SVG stroke, SVG cleanup, feGaussianBlur, SVG glow, SVG blink, shape overlay, page transition, section transition, smooth morph, morph interpolation, dynamic morphing, SVG curtain, shape

1시간 설치 수
1
GitHub Stars
9
업데이트
3월 24일