Skip to main content
March 23, 2026Dan Rodney/8 min read

GreenSock: Staggered Animations & Animating SVG

Master SVG Animation with GreenSock Stagger Effects

Key GSAP Animation Concepts

SVG Animation

Learn to animate Scalable Vector Graphics elements directly in HTML for crisp, scalable animations that work at any resolution.

Transform Origin

Control the anchor point of transformations to create more natural scaling and rotation effects from specific positions.

Stagger Properties

Animate multiple elements sequentially with a single tween, creating wave effects and coordinated motion with minimal code.

Topics Covered in This JavaScript Tutorial:

Animating SVG, Transform Origin, Stagger: Animating Multiple Elements from a Single Tween

Exercise Preview

preview svg stagger

File Structure Setup

The exercise uses the GSAP-SVG-Stagger folder with svg-stagger.html file. The SVG code is embedded directly in HTML rather than using an img tag, allowing access to individual elements for animation.

Exercise Overview

SVG animations represent one of the most powerful yet underutilized techniques in modern web development. In this exercise, you'll master the art of animating Scalable Vector Graphics while discovering GSAP's sophisticated stagger property—a feature that transforms complex multi-element animations into elegant, single-line solutions.

The stagger technique you'll learn here is particularly valuable for creating professional loading sequences, interactive logos, and dynamic user interface elements that can significantly enhance user engagement and brand perception.

Getting Started

  1. For this exercise we'll be working with the GSAP-SVG-Stagger folder located in Desktop > Class Files > JavaScript Class. Open that folder in your code editor if it allows you to (like Visual Studio Code does).
  2. In your code editor, open svg-stagger.html from the GSAP-SVG-Stagger folder.
  3. Preview svg-stagger.html in a browser.

    You'll recognize the Noble Desktop logo from previous exercises, but notice the HTML structure is fundamentally different. Instead of treating the logo as a single image, we've prepared it for granular animation control—allowing us to animate individual letters, shapes, and elements within the logo independently.

  4. Back in your code editor, examine the HTML structure carefully. Understanding this setup is crucial for professional SVG animation work:

    • Rather than using an img tag like previous exercises, we've embedded the complete SVG code directly into our HTML. This inline approach is essential for accessing and animating individual SVG elements—a technique commonly used in production environments for interactive graphics.

      Note: This SVG code was generated by professional design tools such as Adobe Illustrator, Figma, Adobe XD, or Sketch. Modern design-to-code workflows rely heavily on this export capability.

    • Throughout the SVG, you'll encounter <g> tags, which represent groups—the organizational building blocks of complex SVG graphics. These groups were strategically created and named in the design application, automatically converting to unique IDs during SVG export.
    • Study the hierarchical structure of the grouped elements within the SVG logo:

      Noble Desktop (parent container)
      noble (individual letters of "noble")
      desktop (individual letters of "desktop")

      n-background (the rounded rectangle behind the icon)
      n (the colored letter elements)

      This logical grouping enables sophisticated animation control and is a hallmark of well-structured SVG graphics.

Project Setup Process

1

Open Project Folder

Navigate to Desktop > Class Files > JavaScript Class and open the GSAP-SVG-Stagger folder in your code editor

2

Examine SVG Structure

Review the embedded SVG code with grouped elements using g tags and IDs like 'Noble Desktop', 'noble', 'desktop', 'n-background', and 'n'

3

Preview in Browser

Open svg-stagger.html in a browser to see the initial state of the Noble Desktop logo before animation

Creating a Timeline & Solving Display Constraints

Before diving into animations, we need to establish our GSAP timeline and address a common SVG animation challenge: element clipping during transforms.

  1. GSAP has already been linked to this file. In the script tag at the bottom, add the following code to instantiate a new timeline:

    <script>
       let tl = gsap.timeline();
    </script>
  2. Let's immediately identify a critical issue with SVG animations: elements will be cropped when they extend beyond the SVG container boundaries. To demonstrate this, we'll use GSAP's .set method, which instantly applies properties without animation—perfect for initial positioning and debugging.

    Add the following code to move the text group:

    <script>
       let tl = gsap.timeline();
       tl.set('#Noble Desktop', {x:50})
    </script>
  3. Save and reload the page in the browser.

    Notice how the right side of desktop is truncated—this is SVG's default overflow behavior cutting off content that extends beyond the container bounds. This is a common challenge in production SVG animation that we'll resolve with CSS.

  4. Back in your code editor, open main.css from the css folder.
  5. In the #logo rule, add the overflow property:

    #logo {
       overflow: visible;
       width: 100%;
       max-width: 700px;
       height: auto;
    }
  6. Save and reload the page in the browser.

    Perfect! The entire logo is now visible, including elements that extend beyond the original SVG boundaries. This CSS technique is essential for professional SVG animations.

  7. Return to svg-stagger.html and replace the .set method with this entrance animation:

    <script>
       let tl = gsap.timeline();
       tl.from('#Noble Desktop', {duration:.4, scale:0, x:-5})
    </script>
  8. Save and reload the page.

    The text now scales up from zero while sliding slightly from left to right. However, notice the scaling originates from the top-left corner, which feels mechanically awkward. Professional animations require precise control over transformation origins.

Mastering Transform Origin

Transform origin determines the anchor point for scale, rotation, and skew transformations. Mastering this property is crucial for creating polished, professional animations.

  1. Add the transform origin property to control the scaling behavior:

    .from('#Noble Desktop', {duration:.4, scale:0, transformOrigin:'left center', x:-5})

    Professional tip: transformOrigin accepts multiple value formats for maximum flexibility:
    • Keywords: 'left center'
    • Percentages: '0% 50%'
    • Pixels: '0px 25px'

  2. Save and reload the page.

    The animation now scales from the vertical center of the left edge, creating a much more natural and visually pleasing entrance effect. This attention to transformation details separates amateur animations from professional-grade work.

Transform Origin Values

FeatureFormatExample
Keywordsleft centerright top
Percentages0% 50%100% 0%
Pixels10px 20px0px 50px
Recommended: Keyword format is most readable and commonly used for transform origins

Stagger: Orchestrating Multiple Elements with Precision

Now we'll explore GSAP's stagger functionality—one of its most powerful features for creating sophisticated multi-element animations with minimal code. This technique is extensively used in modern web applications for loading sequences, menu animations, and interactive interfaces.

The SVG's g (group) elements provide the perfect structure for staggered animations. Within our Noble Desktop parent group, we have two child groups: noble and desktop, each containing individual letter elements.

  1. Target the direct child groups using CSS's direct descendant selector >:

    .from('#Noble Desktop > g', {duration:.4, scale:0, transformOrigin:'left center', x:-5})
  2. Save and reload the page.

    Both words animate simultaneously. While visually interesting, we want sequential animation to create more dynamic visual flow.

  3. Add the stagger property to create sequential timing:

    .from('#Noble Desktop > g', {duration:.4, scale:0, stagger:1, transformOrigin:'left center', x:-5})
  4. Save and reload the page.

    Now the first word animates, followed by a 1-second delay, then the second word. This demonstrates stagger's basic functionality, but we can create far more impressive effects by animating individual letters.

  5. Reduce the stagger timing for rapid-fire animation:

    .from('#Noble Desktop > g', {duration:.4, scale:0, stagger:0.03, transformOrigin:'left center', x:-5})
  6. Target all nested elements using the wildcard selector:

    .from('#Noble Desktop *', {duration:.4, scale:0, stagger:0.03, transformOrigin:'left center', x:-5})

    The asterisk (*) is a CSS wildcard that selects every element within the Noble Desktop group, giving us granular control over individual letters.

  7. Save and reload the page.

    Excellent! Each letter now animates independently with a subtle 0.03-second delay, creating a sophisticated wave effect across the text. This single line of code replaces what would otherwise require dozens of individual animations.

  8. Add a back ease for enhanced visual appeal:

    .from('#Noble Desktop *', {duration:.4, scale:0, stagger:0.03, transformOrigin:'left center', x:-5, ease:'back.out'})

    Important note: Stagger functionality works with any DOM elements, not just SVG. You can apply this technique to HTML elements, images, cards, buttons—any collection of elements that benefits from sequential animation.

  9. Save and reload the page.

    The back ease adds a delightful bounce effect, giving the animation personality and professional polish. Easing curves are fundamental to creating animations that feel natural and engaging rather than mechanical.

Creating Perpetual Animation Loops

For logo animations and loading sequences, continuous loops with thoughtful pacing can enhance brand presence without becoming distracting.

  1. Configure the timeline for infinite repetition with breathing room between cycles:

    let tl = gsap.timeline({repeat:-1, repeatDelay:1});
  2. Save and reload the page.

    The animation now cycles continuously with a 1-second pause between iterations, allowing viewers to appreciate the completed logo before the next animation cycle begins.

Completing the Logo Animation System

Professional logo animations require cohesive timing and visual hierarchy. Let's animate the remaining logo elements with strategic sequencing.

  1. Add the background rectangle animation that follows the text sequence:

    .from('#Noble Desktop *', {duration:.4, scale:0, stagger:0.03, transformOrigin:'left center', x:-5, ease:'back.out'})
    .from('#n-background', {duration:.3, scale:0, transformOrigin:'right center', ease:'back.out'})
  2. Save and reload the page.

    The black rectangle now appears after the text animation completes, scaling from the right center—creating visual balance with the left-originated text animation.

  3. Complete the sequence by animating the colored icon elements:

    .from('#Noble Desktop *', {duration:.4, scale:0, stagger:0.03, transformOrigin:'left center', x:-5, ease:'back.out'})
    .from('#n-background', {duration:.3, scale:0, transformOrigin:'right center', ease:'back.out'})
    .from('#n *', {duration:.2, scale:0, transformOrigin:'center', stagger:0.03, ease:'back.out'})
  4. Save and reload the page.

    The logo animation is now complete. Each colored element of the 'n' icon appears sequentially in a rapid, polished sequence. This demonstrates GSAP's power: a complex, multi-element professional animation achieved with just three lines of code.

Advanced Timing Control with Position Parameters

Professional animators fine-tune timing relationships between animation sequences to create optimal flow and pacing. GSAP's position parameters provide precise control over when animations begin relative to each other.

  1. Optimize the pacing by overlapping the background animation with the text sequence:

    .from('#n-background', {duration:.3, scale:0, transformOrigin:'right center', ease:'back.out'}, '-=0.3')

    The -=0.3 parameter starts this animation 0.3 seconds before the previous animation completes, creating smooth transitions and eliminating dead time in the sequence.

  2. Save and reload the page.

    The refined timing creates a more fluid, professional animation flow. This overlapping technique is essential for creating dynamic sequences that maintain viewer engagement without feeling rushed or sluggish.

Key Takeaways

1Embed SVG code directly in HTML instead of using img tags to access and animate individual elements within the graphic
2Use transform origin properties to control the anchor point of scaling animations for more natural motion effects
3The stagger property enables sequential animation of multiple elements with a single tween, creating wave effects with minimal code
4CSS overflow: visible on SVG containers prevents animation clipping when elements move outside their original boundaries
5GSAP timelines support repeat and repeatDelay properties for creating looping animations with controlled pacing
6Relative position parameters like '-=0.3' allow animations to overlap in time, creating smoother and faster overall sequences
7The asterisk (*) wildcard selector targets all child elements, enabling granular control over complex nested SVG structures
8Easing functions like 'back.out' add personality and polish to animations with minimal additional code

RELATED ARTICLES