About
Blog Case Studies Work with us
Frontend · Feb 12, 2026 · ⏱ 7 min read

Getting Started with Animations Using GSAP

Modern websites don't just display information — they create experiences. Learn how GSAP gives you full control over timing, sequencing, and scroll-based animations to make your UI feel truly alive.

AP
Adish Prajapati Fro Intern· ORA Technology
Web animation and GSAP development
GSAP Animation ScrollTrigger
You've probably noticed that modern websites don't just display information — they create experiences. When you visit a well-designed website, you can immediately feel the difference. Elements fade in smoothly, sections slide into place as you scroll, and buttons respond subtly when you hover over them. These small details make a website feel alive.

Animation plays a huge role in improving User Experience (UX). It:

  • Guides user attention
  • Creates visual hierarchy
  • Makes interactions feel intuitive

For example, when content animates into view as you scroll, it tells a story instead of overwhelming users with everything at once. These subtle movements are called micro-interactions, and they help users understand what's happening on the screen without even realizing it.

Animations are powerful storytelling tools. A smooth hero reveal, staggered text animation, or scroll-based section transition can turn a simple webpage into an engaging journey. Instead of just reading content, users experience it.

Why Not Just Use CSS?

CSS animations and transitions are great for:

  • Simple hover effects
  • Small movements
  • Basic UI interactions

They are lightweight and perfect for simple tasks.

However, when your design requires:

  • Complex animation sequences
  • Precise timing control
  • Scroll-based animations

CSS can start to feel limiting. That's where GSAP comes in. It gives you full control over timing, sequencing, easing, and scroll behavior — making professional-grade animations much easier to build.

What is GSAP?

GSAP (GreenSock Animation Platform) is a high-performance JavaScript animation library that allows developers to create smooth, professional-grade animations for the web.

With GSAP, you can control how elements:

Move across the screen with precise positioning control
Scale up and down smoothly with easing functions
Rotate and transform with GPU-accelerated performance
Fade in and out using opacity and visibility controls

It works seamlessly with DOM elements, SVG graphics, and Canvas elements. Because of its flexibility and performance, GSAP has become a go-to tool for modern frontend developers who want full creative control over animations.

Key Features of GSAP

1️⃣ Timeline Control

One of GSAP's most powerful features is its timeline system. Instead of manually managing delays and durations, you can create a timeline and sequence animations in a clean, organized way. With timelines, you can chain animations, overlap them, control playback (pause, resume, reverse), and create complex sequences with minimal code.

2️⃣ Scroll-Based Animations

Modern websites rely heavily on scroll-driven interactions. With ScrollTrigger (a GSAP plugin), you can trigger animations when elements enter the viewport, pin sections while scrolling, sync animation progress with scroll position, and create immersive storytelling layouts.

3️⃣ Cross-Browser Consistency

Animations can behave differently across browsers. GSAP handles many of these inconsistencies internally, ensuring smooth performance across Chrome, Firefox, Safari, and Edge.

4️⃣ Smooth Performance

GSAP focuses on animating GPU-accelerated properties like transform and opacity, keeping animations smooth even on lower-powered devices.

Installation and Setup

Before you start animating, you need to add GSAP to your project.

Option 1: Using a CDN

If you're experimenting or building a simple HTML project, add this before the closing </body> tag:

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

That's it — you're ready to use GSAP.

Option 2: Using npm

If you're using React, Vite, Webpack, or another modern setup:

npm install gsap

Then import it in your JavaScript file:

import gsap from "gsap";

Your First Animation

HTML

<div class="box"></div>

CSS

body {
  background-color: #333;
  align-items: center;
}
 
.box {
  height: 100px;
  width: 100px;
  background-color: #4ade80;
}

JavaScript

gsap.to(".box", {
  x: 200,
  duration: 1,
  rotation: 360
});
💡
What's Happening Here?
gsap.to() animates an element to a specific state. x: 200 moves it 200px on the X-axis. duration: 1 makes the animation last 1 second. rotation: 360 spins it a full turn. Result: The box moves to the right and spins in one second.

Understanding to() vs from()

to()

Animates from the current state to a new state.

gsap.to(".box", { x: 200 });

from()

Animates from a defined starting state to the current state.

gsap.from(".box", {
  x: -200,
  opacity: 0,
  duration: 1
});

This means the element starts 200px to the left, starts invisible, then animates into its normal position. This is commonly used for reveal animations.

Other Important Properties

  • Duration – How long the animation runs
  • Delay – Wait time before the animation starts
  • Ease – Controls motion style (makes movement feel natural instead of robotic)

Core Concepts

🔹 Tween (Single Animation)

A tween is one animation. Each separate animation you write is a tween. Managing many individual tweens can become messy.

gsap.to(".box", { x: 200 });

🔹 Timeline (Sequence of Animations)

Timelines make animation sequencing easy — no need to manually calculate delays.

const tl = gsap.timeline();
 
tl.to(".box", { x: 200 })
  .to(".circle", { y: 100 });

This moves the box first, then moves the circle.

Scroll Animations with ScrollTrigger

ScrollTrigger allows animations to run based on scroll position.

Important Properties

  • trigger – Element that activates the animation
  • start – When animation begins (e.g., "top 80%")
  • end – When animation stops
  • scrub – Links animation progress to scroll
  • pin – Keeps an element fixed while animating

Example

gsap.registerPlugin(ScrollTrigger);
 
gsap.fromTo(".box",
  {
    scale: 0.5,
    rotation: 0,
    opacity: 0
  },
  {
    scale: 1.5,
    rotation: 360,
    opacity: 1,
    scrollTrigger: {
      trigger: ".animation",
      start: "top center",
      end: "bottom center",
      scrub: true
    }
  }
);

CSS vs GSAP

🎨

When to Use CSS

Use CSS for simple hover effects, basic fade-ins, small UI interactions, and when you want minimal JavaScript overhead.

button:hover {
  transform: scale(1.1);
}

Clean, simple, and fast.

When to Use GSAP

Use GSAP for animation sequencing, multiple elements animating in order, scroll-based interactions, precise timing control, and professional smooth motion. If your animation feels like a system rather than a small effect, GSAP is usually the better choice.

Final Thoughts

Animations can transform a website from "just functional" to truly engaging. With GSAP, you gain full control over timing, sequencing, and scroll-based interactions — all while maintaining smooth performance across browsers.

Whether you're building a subtle hover effect, a hero reveal, or a full scroll storytelling experience, GSAP makes complex animations simple and enjoyable to implement.

The best way to learn is to experiment:

  • Tweak durations
  • Play with timelines
  • Combine from(), to(), and fromTo()
  • Observe how your UI comes to life
Start small, build gradually, and soon your websites won't just display content — they'll tell a story.
AP
Adish Prajapati
Frontend Intern· ORA Technology

Adish specialises in modern frontend development with a focus on animation, performance, and user experience. He contributes to ORA's frontend engineering practice and writes about JavaScript, GSAP, and creative web development.

Back to all articles