{"id":1768,"date":"2025-03-29T08:19:33","date_gmt":"2025-03-29T08:19:33","guid":{"rendered":"https:\/\/codebox.keyframetechsolution.com\/?p=1768"},"modified":"2025-03-29T08:23:25","modified_gmt":"2025-03-29T08:23:25","slug":"scroll-animations-on-website-with-gsap-scrolltrigger","status":"publish","type":"post","link":"https:\/\/codebox.keyframetechsolution.com\/scroll-animations-on-website-with-gsap-scrolltrigger\/","title":{"rendered":"Create a Website with Scroll Animations Using GSAP ScrollTrigger"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p><span data-preserver-spaces=\"true\">Building interactive and engaging websites has become more important than ever. One way to add a touch of excitement to your website is by implementing scroll animations. <\/span><\/p>\n<p><span data-preserver-spaces=\"true\">With its help, you can create a dynamic user experience by animating elements to move, fade, or scale as the user scrolls down the page, making <\/span><span data-preserver-spaces=\"true\">it easy to add<\/span><span data-preserver-spaces=\"true\"> such animations to your website.<\/span><\/p>\n<p><span data-preserver-spaces=\"true\">In this tutorial, I will show you how to create a website with scroll animations using GSAP ScrollTrigger.<\/span><\/p>\n<p>\u2705\u00a0<strong>Watch Live Preview<\/strong>\u00a0\ud83d\udc49\ud83d\udc49<\/p>\n<p><iframe title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/o8Qn78Gwn24?si=L6x0cwvDNy4fWAjp\" width=\"100%\" height=\"400\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p><a href=\"#conclusion\">Click Here to Download the Code<\/a><\/p>\n<h2><span data-preserver-spaces=\"true\">What is GSAP ScrollTrigger?<\/span><\/h2>\n<p><span data-preserver-spaces=\"true\"><br \/>\nGSAP is a popular JavaScript library for animations, offering a fast and efficient way to create complex animations with minimal code. One of its most powerful features is that it allows us to trigger animations based on the <\/span><span data-preserver-spaces=\"true\">user&#8217;s<\/span><span data-preserver-spaces=\"true\"> scroll position. <\/span><\/p>\n<p><span data-preserver-spaces=\"true\">With this, you can animate elements depending on how far the user has scrolled, control animations based on the scroll direction, and synchronize animations with the scroll position for smooth, responsive results.<\/span><\/p>\n<h2 id=\"section2\">What are the Steps to Begin?<\/h2>\n<p>First, create a folder on your computer and add the following files inside it:<\/p>\n<ul>\n<li><strong>index.html<\/strong><\/li>\n<li><strong>style.css<\/strong><\/li>\n<li><strong>script.js<\/strong><\/li>\n<\/ul>\n<p><strong>You May Also Like:<\/strong> <a href=\"https:\/\/codebox.keyframetechsolution.com\/gsap-scrolltrigger-animation\/\">How to Create ScrollTrigger Animations with GSAP<\/a><\/p>\n<h2><span data-preserver-spaces=\"true\">Adding GSAP and ScrollTrigger<\/span><\/h2>\n<p><span data-preserver-spaces=\"true\"><br \/>\nYou can easily add it to your project using a CDN (<a href=\"https:\/\/www.cloudflare.com\/en-gb\/learning\/cdn\/what-is-a-cdn\/\" rel=\"nofollow noopener\" target=\"_blank\">Content Delivery Network<\/a>). In the &lt;head&gt; section of your HTML file, add the following lines:<\/span><\/p>\n<p><strong>&lt;!&#8211; GSAP CDN &#8211;&gt;<\/strong><\/p>\n<p><span data-preserver-spaces=\"true\">&lt;script src=&#8221;https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/gsap\/3.11.1\/gsap.min.js&#8221;&gt;&lt;\/script&gt;<\/span><\/p>\n<p><strong>&lt;!&#8211; ScrollTrigger CDN &#8211;&gt;<\/strong><\/p>\n<p><span data-preserver-spaces=\"true\">&lt;script src=&#8221;https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/gsap\/3.11.1\/ScrollTrigger.min.js&#8221;&gt;&lt;\/script&gt;<\/span><\/p>\n<p><span data-preserver-spaces=\"true\">Adding this line of code will load the GSAP library and the ScrollTrigger plugin, both crucial for creating scroll animations.<\/span><\/p>\n<h2><span data-preserver-spaces=\"true\">Source Code<\/span><\/h2>\n<h3><span data-preserver-spaces=\"true\">HTML Code<\/span><\/h3>\n<div class=\"code-container\">\n<div class=\"toolbar\">\n<div class=\"actions\">\n        <span><\/span><br \/>\n        <span class=\"yellow\"><\/span><br \/>\n        <span class=\"green\"><\/span>\n      <\/div>\n<div class=\"title\">index.html<\/div>\n<\/p><\/div>\n<div class=\"code-content\">\n<pre><code class=\"language-markup\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=\"en\"&gt;\r\n&lt;head&gt;\r\n  &lt;meta charset=\"UTF-8\"&gt;\r\n  &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\r\n  &lt;title&gt;Create a Website with Scroll Animations Using GSAP ScrollTrigger&lt;\/title&gt;\r\n  &lt;link rel=\"stylesheet\" href=\"style.css\"&gt;\r\n  &lt;link rel=\"stylesheet\" href=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/font-awesome\/4.7.0\/css\/font-awesome.min.css\"&gt;\r\n  &lt;link rel=\"stylesheet\" href=\"https:\/\/fonts.googleapis.com\/css2?family=Poppins:wght@400;500;600;700&amp;family=Ubuntu:wght@400;500;700&amp;display=swap\"&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;!-- CODE --&gt;\r\n\r\n&lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/gsap\/3.11.1\/gsap.min.js\"&gt;&lt;\/script&gt;\r\n&lt;script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/gsap\/3.11.1\/ScrollTrigger.min.js\"&gt;&lt;\/script&gt;\r\n&lt;script src=\"script.js\"&gt;&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<h3><span data-preserver-spaces=\"true\">CSS Code<\/span><\/h3>\n<div class=\"code-container\">\n<div class=\"toolbar\">\n<div class=\"actions\">\n        <span><\/span><br \/>\n        <span class=\"yellow\"><\/span><br \/>\n        <span class=\"green\"><\/span>\n      <\/div>\n<div class=\"title\">style.css<\/div>\n<\/p><\/div>\n<div class=\"code-content\">\n<pre><code class=\"language-markup\">\r\n&lt; \/* Your CSS code here *\/ &gt;\r\n&lt; * { &gt;\r\n\r\n&lt; margin: 0; &gt;\r\n&lt; padding: 0 &gt;\r\n&lt; box-sizing: border-box; &gt;\r\n&lt;     text-decoration: none; &gt;\r\n&lt;     } &gt;\r\n      <\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<h3><span data-preserver-spaces=\"true\">JavaScript Code<\/span><\/h3>\n<div class=\"code-container\">\n<div class=\"toolbar\">\n<div class=\"actions\">\n        <span><\/span><br \/>\n        <span class=\"yellow\"><\/span><br \/>\n        <span class=\"green\"><\/span>\n      <\/div>\n<div class=\"title\">script.js<\/div>\n<\/p><\/div>\n<div class=\"code-content\">\n<pre><code class=\"language-markup\">\r\n&lt; \/\/ JavaScript Code &gt;\r\n      <\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<p><strong>You May Also Like: <\/strong><a href=\"https:\/\/codebox.keyframetechsolution.com\/scrolltrigger-canvas-animations\/\">Create Dynamic Canvas Animations with GSAP ScrollTrigger<\/a><\/p>\n<h2 id='conclusion'><span data-preserver-spaces=\"true\">Conclusion<\/span><\/h2>\n<p><span data-preserver-spaces=\"true\">In this<\/span><span data-preserver-spaces=\"true\"> tutorial<\/span><span data-preserver-spaces=\"true\">, we<\/span><span data-preserver-spaces=\"true\"> demonstrated how to create a landing page with scroll-triggered animations using GSAP ScrollTrigger.<\/span> <span data-preserver-spaces=\"true\">By adding<\/span><span data-preserver-spaces=\"true\"> smooth animations that respond to scrolling<\/span><span data-preserver-spaces=\"true\">, you<\/span><span data-preserver-spaces=\"true\"> can enhance the user experience and make your website more interactive and visually engaging.<\/span><\/p>\n<p><span data-preserver-spaces=\"true\">This<\/span><span data-preserver-spaces=\"true\"> is just the beginning. With this, you can create more complex animations such as parallax effects, page transitions, and even full-screen scroll effects. <\/span><\/p>\n<p><span data-preserver-spaces=\"true\">Experiment with different trigger points, animation timings, and effects to craft unique scroll animations tailored to your <\/span><span data-preserver-spaces=\"true\">website\u2019s<\/span><span data-preserver-spaces=\"true\"> needs.<\/span><\/p>\n<p><strong><i class=\"fa fa-download\" style=\"color: #046bd2;\"><\/i> 7 people bought this<\/strong><\/p>\n<p>Hurry, Get it Now for Only <i class=\"fa fa-rupee\" style=\"color: #046bd2;\"><\/i><span style=\"color: #046bd2;\">100<\/span> <del>\u20b9399<\/del><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Building interactive and engaging websites has become more important than ever. One way to add a touch of excitement [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1772,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[3,351],"tags":[484,483,481,383,482],"class_list":["post-1768","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-page","category-offer","tag-create-scroll-animations-on-website-with-gsap-scrolltrigger","tag-gsap-animation-examples","tag-gsap-scroll-animation","tag-gsap-scrolltrigger","tag-gsap-website-examples"],"acf":[],"_links":{"self":[{"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts\/1768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/comments?post=1768"}],"version-history":[{"count":9,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts\/1768\/revisions"}],"predecessor-version":[{"id":1780,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/posts\/1768\/revisions\/1780"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/media\/1772"}],"wp:attachment":[{"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/media?parent=1768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/categories?post=1768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codebox.keyframetechsolution.com\/wp-json\/wp\/v2\/tags?post=1768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}