<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged gsap</title>
<link>https://coderlegion.com/tag/gsap</link>
<description>Powered by Question2Answer</description>
<item>
<title>Animate Like a Pro: Build a Modern Scroll-Triggered Website with GSAP</title>
<link>https://coderlegion.com/3647/animate-like-a-pro-build-a-modern-scroll-triggered-website-with-gsap</link>
<description>&lt;p&gt; Introduction&lt;/p&gt;
&lt;p&gt;Modern websites aren’t just static layouts—they breathe, respond, and tell stories. In this guide, we’ll walk through how to build a modern, scroll-triggered, animation-rich website using GSAP (GreenSock Animation Platform).&lt;/p&gt;
&lt;p&gt;Inspired by top-tier Awwwards websites, this post teaches you how to:&lt;/p&gt;
&lt;p&gt;Animate text on page load&lt;/p&gt;
&lt;p&gt;Trigger elements on scroll&lt;/p&gt;
&lt;p&gt;Create parallax effects&lt;/p&gt;
&lt;p&gt;Add interactive hover animations&lt;/p&gt;
&lt;p&gt;Optimize for performance and responsiveness&lt;/p&gt;
&lt;p&gt;All with clean code and professional structure.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Setting Up Your Project&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Create your basic folder structure:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;project/
├── index.html
├── styles.css
└── script.js
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;index.html&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;section class=&quot;hero&quot;&amp;gt;
  &amp;lt;h1 class=&quot;headline&quot;&amp;gt;We Design for Impact&amp;lt;/h1&amp;gt;
  &amp;lt;button class=&quot;cta&quot;&amp;gt;Discover More&amp;lt;/button&amp;gt;
&amp;lt;/section&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;styles.css&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;body {
  margin: 0;
  font-family: 'Poppins', sans-serif;
  background: #121212;
  color: #fff;
}

.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Include GSAP via CDN in your HTML:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;script src=&quot;https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src=&quot;https://cdn.jsdelivr.net/npm/gsap@3/dist/ScrollTrigger.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;ol&gt;
&lt;li&gt;Animate Hero Section with GSAP Timeline&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let’s animate the headline and button on page load using gsap.timeline():&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;const tl = gsap.timeline();

tl.from(&quot;.headline&quot;, {
  y: 100,
  opacity: 0,
  duration: 1.2,
  ease: &quot;power4.out&quot;
})
.from(&quot;.cta&quot;, {
  y: 20,
  opacity: 0,
  duration: 1,
  ease: &quot;back.out(1.7)&quot;
}, &quot;-=0.5&quot;);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; Result: Smooth fade-in entrance animation with professional timing and bounce.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;ScrollTrigger Section Animations&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Create reusable section reveals using ScrollTrigger:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;section class=&quot;section&quot;&amp;gt;About&amp;lt;/section&amp;gt;
&amp;lt;section class=&quot;section&quot;&amp;gt;Projects&amp;lt;/section&amp;gt;
&amp;lt;section class=&quot;section&quot;&amp;gt;Contact&amp;lt;/section&amp;gt;

gsap.utils.toArray(&quot;.section&quot;).forEach(section =&amp;gt; {
  gsap.from(section, {
    scrollTrigger: {
      trigger: section,
      start: &quot;top 85%&quot;,
      toggleActions: &quot;play none none reverse&quot;
    },
    y: 100,
    opacity: 0,
    duration: 1
  });
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; Result: Each section fades and slides in when scrolled into view.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a Parallax Effect&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Use a parallax background for depth:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&quot;parallax-wrapper&quot;&amp;gt;
  &amp;lt;img src=&quot;bg.jpg&quot; class=&quot;bg-image&quot; /&amp;gt;
&amp;lt;/div&amp;gt;

.parallax-wrapper {
  position: relative;
  height: 100vh;
  overflow: hidden;
}
.bg-image {
  position: absolute;
  width: 100%;
  top: 0;
  z-index: -1;
}

gsap.to(&quot;.bg-image&quot;, {
  scrollTrigger: {
    trigger: &quot;.parallax-wrapper&quot;,
    scrub: true,
  },
  y: &quot;-30%&quot;,
  ease: &quot;none&quot;
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; Result: Smooth scroll-linked background motion—eye-catching and modern.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Add Hover Animation to Elements&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Create hover-based animations for interactive elements:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&quot;card&quot;&amp;gt;Hover me&amp;lt;/div&amp;gt;

.card {
  width: 200px;
  height: 200px;
  background: #1e1e1e;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s;
}

document.querySelectorAll(&quot;.card&quot;).forEach(card =&amp;gt; {
  card.addEventListener(&quot;mouseenter&quot;, () =&amp;gt; {
    gsap.to(card, { scale: 1.05, duration: 0.3 });
  });
  card.addEventListener(&quot;mouseleave&quot;, () =&amp;gt; {
    gsap.to(card, { scale: 1, duration: 0.3 });
  });
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; Result: Subtle interactivity that improves UX without overwhelming.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Responsive &amp;amp; Mobile Optimization&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Use ScrollTrigger.matchMedia() to conditionally control animations based on screen size:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ScrollTrigger.matchMedia({
  &quot;(min-width: 768px)&quot;: function() {
    gsap.from(&quot;.cta&quot;, {
      y: 50,
      opacity: 0,
      duration: 1,
      scrollTrigger: {
        trigger: &quot;.cta&quot;,
        start: &quot;top 80%&quot;
      }
    });
  }
});
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; Pro Tip: Disable or simplify animations for low-powered mobile devices.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Final Touches &amp;amp; Best Practices&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Use performance-friendly easing like &quot;power2.out&quot; or &quot;none&quot; for scroll-linked effects&lt;/p&gt;
&lt;p&gt;Use will-change CSS property for elements that animate&lt;/p&gt;
&lt;p&gt;Avoid layout jank: Animate transform, not top/left&lt;/p&gt;
&lt;p&gt; Bonus: What Makes It Awwwards-Worthy?&lt;/p&gt;
&lt;p&gt;Consistent motion rhythm&lt;/p&gt;
&lt;p&gt;Smooth easing and microinteractions&lt;/p&gt;
&lt;p&gt;Strategic use of white space and bold type&lt;/p&gt;
&lt;p&gt;Layered visual depth (z-index, parallax, lighting)&lt;/p&gt;
&lt;p&gt;✅ Conclusion&lt;/p&gt;
&lt;p&gt;This step-by-step journey demonstrates how to transform basic markup into a sophisticated, animated web experience using GSAP. Whether you're enhancing a portfolio, creating a product landing page, or experimenting with scroll-based storytelling, GSAP and ScrollTrigger give you the control and fluidity needed to stand out.&lt;/p&gt;
</description>
<category>Frontend Dev</category>
<guid isPermaLink="true">https://coderlegion.com/3647/animate-like-a-pro-build-a-modern-scroll-triggered-website-with-gsap</guid>
<pubDate>Mon, 30 Jun 2025 06:17:22 +0000</pubDate>
</item>
</channel>
</rss>