[
    {
        "summary": "What's GSAP?",
        "content": "<p>GSAP (GreenSock Animation Platform) is a JavaScript library for creating high-performance animations on the web. You give it an HTML element, tell it what to animate and how long to take, and it handles the rest. It works with any setup — a plain HTML page, a CMS, or a JavaScript framework — because at its core it just targets DOM elements and changes their properties over time. Animations run at a smooth 60fps and the library is lightweight, so your pages stay fast.</p>"
    },
    {
        "summary": "Installation",
        "content": "<p>You have two ways to add GSAP to your project:</p><br><p><strong>npm (recommended for larger projects):</strong></p><pre><code>npm install gsap</code></pre><p>Then import it in your JavaScript:</p><pre><code>import gsap from 'gsap';</code></pre><br><p><strong>CDN (quick start — just add a script tag):</strong></p><pre><code>&lt;script src=\"https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js\"&gt;&lt;/script&gt;</code></pre><p>That's it — no build step. Once the script loads, code>gsap</code> is available globally and you can start animating immediately.</p>"
    },
    {
        "summary": "Making a Basic Tween",
        "content": "<p>A <strong>tween</strong> is a single animation that changes a property from one value to another. There are three main methods depending on how you want to control the start and end:</p><br><p><strong>gsap.to()</strong> — Animates from the element's current state <em>to</em> the values you specify:</p><pre><code>gsap.to(\".box\", { x: 200, duration: 1 });</code></pre><p>This moves any element with the class <code>box</code> 200px to the right over 1 second.</p><br><p><strong>gsap.from()</strong> — Animates <em>from</em> the specified values <em>to</em> the element's current state:</p><pre><code>gsap.from(\".box\", { opacity: 0, y: 50, duration: 1 });</code></pre><p>The box starts invisible and 50px lower, then fades and slides into place.</p><br><p><strong>gsap.fromTo()</strong> — Full control over both start and end values:</p><pre><code>gsap.fromTo(\".box\",\n    { opacity: 0, x: -100 },\n    { opacity: 1, x: 0, duration: 1 }\n);</code></pre><br><p><strong>Breaking it down:</strong> Each method takes a <strong>target</strong> (a CSS selector string, a DOM element reference, or an array of elements) and a strong>vars</strong> object with the properties you want to animate. Any numeric CSS property, color, or transform can go in the vars object.</p>"
    },
    {
        "summary": "Making a Timeline",
        "content": "<p>When you want to <strong>sequence</strong> multiple animations one after another (or overlap them), use a <strong>timeline</strong>. A timeline is a container that holds tweens and plays them in order:</p><pre><code>const tl = gsap.timeline();\n\ntl.to(\".box\", { x: 200, duration: 1 })\n  .to(\".box\", { y: 200, duration: 0.5 })\n  .to(\".box\", { rotation: 360, duration: 0.75 });</code></pre><p>By default, each tween starts when the previous one finishes. You can overlap them using the <strong>position parameter</strong>:</p><pre><code>const tl = gsap.timeline();\n\ntl.to(\".box\", { x: 200, duration: 1 })\n  .to(\".box\", { rotation: 180, duration: 0.5 }, \"-=0.25\") // starts 0.25s early\n  .to(\".box\", { scale: 1.5, duration: 0.3 }, 0.5);        // starts 0.5s into the timeline</code></pre><p>The position parameter accepts:</p><ul><li><strong>Absolute time</strong> (seconds) — <code>0.5</code> starts at 0.5s.</li><li><strong>Relative to end</strong> — <code>\"-=0.25\"</code> starts 0.25s before the timeline ends.</li><li><strong>Label</strong> — <code>\"myLabel\"</code> inserts at a named label.</li><li><strong>\"&lt;\"</strong> — starts at the same time as the previous tween's start.</li></ul><br><p>Timelines give you control over the whole sequence: <code>tl.pause()</code>, <code>tl.play()</code>, <code>tl.reverse()</code>, <code>tl.seek(1.5)</code>, and <code>tl.timeScale(2)</code> to speed things up.</p>"
    },
    {
        "summary": "Variables",
        "content": "<p>These are the properties you put inside a tween's vars object to control what happens and how it looks.</p><br><p><strong>Transform properties (performant — uses CSS transforms under the hood):</strong></p><p><code>x, y, z</code> — Move an element along each axis (in pixels). Use <code>z</code> with 3D rendering.</p><p><code>rotation</code> — Rotate in degrees (<code>360</code> = one full spin).</p><p><code>rotationX, rotationY, rotationZ</code> — 3D rotation on a specific axis.</p><p><code>scale</code> — Uniform scale. <code>2</code> = double size, <code>0.5</code> = half.</p><p><code>scaleX, scaleY</code> — Scale only horizontally or vertically.</p><p><code>skewX, skewY</code> — Skew (tilt) an element along an axis.</p><br><p><strong>Visual properties:</strong></p><p><code>opacity</code> — <code>0</code> (invisible) to <code>1</code> (fully visible).</p><p><code>autoAlpha</code> — Shorthand that combines <code>opacity</code> and <code>visibility</code>. When it reaches <code>0</code>, the element is hidden from screen readers and keyboard focus.</p><p><code>color, backgroundColor</code> — Animate text or background color (hex, rgba, or named colors).</p><p><code>borderRadius</code> — Animate rounded corners.</p><p><code>width, height</code> — Animate dimensions.</p><br><p><strong>Timing &amp; control:</strong></p><p><code>duration</code> — How long the animation runs in seconds. Default <code>0.5</code>.</p><p><code>delay</code> — Wait time before the animation starts (seconds).</p><p><code>repeat</code> — Number of repeats. <code>-1</code> loops forever.</p><p><code>repeatDelay</code> — Pause between repeats.</p><p><code>yoyo</code> — When <code>true</code>, the animation reverses back to the start on each repeat (like a yo-yo).</p><p><code>ease</code> — The easing curve (see the Easing section below).</p><p><code>stagger</code> — If multiple elements are targeted, staggers their start times. <code>0.1</code> means each element starts 0.1s after the previous one.</p><br><p><strong>Callbacks &amp; advanced:</strong></p><p><code>onStart</code> — Function called when the animation begins.</p><p><code>onComplete</code> — Function called when the animation finishes.</p><p><code>onUpdate</code> — Function called on every frame during the animation.</p><p><code>onRepeat</code> — Function called each time a repeat occurs.</p><p><code>paused</code> — If <code>true</code>, the animation starts paused. Call <code>.play()</code> to begin.</p><p><code>immediateRender</code> — If <code>true</code>, the tween jumps to its end state immediately upon creation (useful with <code>from()</code>).</p><p><code>overwrite</code> — Controls whether existing tweens on the same target are killed. <code>\"auto\"</code> (default) handles it intelligently.</p><p><code>id</code> — A string label you can use to find the tween later with <code>gsap.getById()</code>.</p><p><code>timeScale</code> — Multiplier for animation speed. <code>2</code> = double speed, <code>0.5</code> = half speed.</p><p><code>progress</code> — A number between <code>0</code> and <code>1</code> to jump to a specific point in the animation.</p>"
    },
    {
        "summary": "Easing",
        "content": "<p>Easing controls how an animation <strong>accelerates</strong> and <strong>decelerates</strong> over time. Without easing, everything moves at a constant speed — it feels robotic. Easing adds a natural feel of real-world motion.</p><br><p>Apply it with the <code>ease</code> property:</p><pre><code>gsap.to(\".box\", { x: 300, duration: 1, ease: \"power2.out\" });</code></pre><br><p><strong>Common easing types:</strong></p><p><code>power1.out</code> — Gentle deceleration at the end. Good for fades and small slides.</p><p><code>power2.out</code> — Moderate deceleration. The most popular choice for UI animations.</p><p><code>power3.out</code> — Strong deceleration — the element glides smoothly to a stop.</p><p><code>power1.in</code> — Starts slow and speeds up (like a car accelerating).</p><p><code>power1.inOut</code> — Slow start, fast middle, slow end — natural for object motion.</p><p><code>elastic.out</code> — Overshoots then bounces back to settle. Great for attention-grabbing effects.</p><p><code>bounce.out</code> — Simulates dropping — the element bounces a few times before stopping.</p><p><code>back.in</code> — Moves slightly <em>backward</em> before springing forward to the target.</p><p><code>circ.inOut</code> — Circular motion curve for very smooth starts and stops.</p><p><code>none</code> / <code>linear</code> — Constant speed, no easing.</p><br><p><strong>Easing patterns explained:</strong></p><p><code>.in</code> — Accelerates (slow &rarr; fast).</p><p><code>.out</code> — Decelerates (fast &rarr; slow). Use this for elements entering the screen.</p><p><code>.inOut</code> — Both (slow &rarr; fast &rarr; slow). Use this for elements moving between two points.</p><br><p>GSAP has many more easings. Try them visually at the <a href=\"https://greensock.com/ease-visualizer/\" target=\"_blank\" rel=\"noopener noreferrer\">GSAP Ease Visualizer</a>.</p>"
    },
    {
        "summary": "Cleanup",
        "content": "<p>If a GSAP animation is still running when you remove its target elements from the page (or navigate away), the animation <strong>continues in memory</strong>. This causes memory leaks and unwanted behavior — the tweens keep trying to update elements that no longer exist.</p><br><p><strong>Always clean up your tweens and timelines.</strong></p><br><p><strong>Kill a single tween:</strong></p><pre><code>const tween = gsap.to(\".box\", { x: 200, duration: 1 });\n\n// Later, when cleaning up:\ntween.kill();</code></pre><br><p><strong>Kill all tweens on a specific target:</strong></p><pre><code>gsap.killTweensOf(\".box\");</code></pre><br><p><strong>Kill a timeline:</strong></p><pre><code>const tl = gsap.timeline();\ntl.to(\".box\", { x: 200, duration: 1 })\n  .to(\".box\", { rotation: 360, duration: 0.5 });\n\n// Later, when cleaning up:\ntl.kill();</code></pre><br><p><strong>Revert to the original state:</strong></p><pre><code>gsap.set(\".box\", { x: 0, rotation: 0 });</code></pre><p>Or use the <code>revert()</code> method if you're using GSAP's <code>ScrollTrigger</code> or other plugins that track changes.</p><br><p><strong>Clean up event listeners too:</strong> If your code attaches event listeners (like <code>resize</code> or <code>scroll</code> handlers), always remove them when they're no longer needed:</p><pre><code>window.removeEventListener(\"resize\", handleResize);</code></pre><br><p>Keeping a reference to every tween and timeline you create — and killing them when you're done — prevents memory leaks and ensures animations don't fire on elements that have been removed from the page.</p>"
    }
]