Creating an Airport Schedule-Style Text Animation with GSAP

If you’ve ever been fascinated by the flipping text animations on airport flight schedule boards, you can bring a similar effect to your website using GSAP (GreenSock Animation Platform). In this tutorial, we’ll create an eye-catching text animation that triggers when it enters the viewport.

Why Use GSAP?

GSAP is a powerful JavaScript library that makes complex animations easy to implement. With ScrollTrigger, we can control when animations start based on the user’s scrolling behavior.


Building the Airport Text Animation

Step 1: Setting Up the HTML

First, we need a basic structure with a container that will hold our animated text.

<!-- Head Code - Gsap Lib -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js"></script>
    
<!-- body code -->
<div class="container">
    <div class="airportanimation" data-text="GSAP On Scroll Airport Schedule Animation">
        GSAP On Scroll Airport Schedule Animation
    </div>
</div>

The data-text attribute stores the text that will be animated.

Step 2: Styling with CSS

We want our text to look sleek, bold, and similar to an airport schedule display. We also ensure it aligns well within the viewport.

body {
    font-family: Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200vh; /* Enables scrolling */
    background-color: #111;
    color: #fff;
}
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 50vh;
}
.airportanimation {
    font-size: 2rem;
    font-weight: bold;
    letter-spacing: 3px;
    font-family: monospace;
    background-color: black;
    padding: 10px 20px;
    border-radius: 5px;
    display: inline-block;
    white-space: nowrap;
}

Step 3: Adding the GSAP Animation

Now, let’s animate the text so each character appears sequentially as if it’s flipping into place when scrolled into view.

document.addEventListener("DOMContentLoaded", function () {
    gsap.registerPlugin(ScrollTrigger);

    document.querySelectorAll(".airportanimation").forEach(el => {
        let text = el.getAttribute("data-text");
        let chars = text.split("");
        el.innerHTML = "";
        chars.forEach((char, index) => {
            let span = document.createElement("span");
            span.textContent = char === " " ? "\u00A0" : char; // Preserve spaces
            span.style.display = "inline-block";
            el.appendChild(span);
        });

        gsap.fromTo(el.children,
            { opacity: 0, y: -10 },
            { opacity: 1, y: 0, stagger: 0.1, ease: "power2.out",
              scrollTrigger: {
                  trigger: el,
                  start: "top 80%",
                  toggleActions: "play none none none"
              }
            }
        );
    });
});

How It Works

  1. Splitting Text into Characters: Each letter (including spaces) is wrapped in a <span> so they can be animated individually.
  2. Animating with GSAP: The animation starts when the text enters the viewport (80% from the top).
  3. Sequential Stagger Effect: Each character appears one after the other, creating a flipping effect similar to airport schedule boards.

Final Thoughts

This GSAP-powered text animation adds an engaging and professional touch to your website. By combining GSAP with ScrollTrigger, you can create stunning effects that enhance user experience.

Give it a try and tweak the settings to create your own custom animations!

CodePen Demo:

See the Pen GSAP Airport Text Animation – Onscroll Viewport by Mossawir (@mossawir) on CodePen.

Ready to bring your vision to life? Let's start your web development project today!

Latest Posts

Check out my latest blog posts for valuable insights, tips, and trends in web development and design that can help elevate your projects!

At Mossawir.com, we are committed to protecting the privacy of our clients and website visitors. This Privacy Policy outlines how I collect, use, and protect your personal information when you visit our website or engage with our services.

1. Information I Collect

I collect the following types of information to provide better services to our clients:

  • Personal Information: This includes your name, email address, phone number, and any other information you provide through contact forms or when communicating with us.
  • Technical Information: I may collect data such as your IP address, browser type, device information, and browsing behavior through cookies and similar tracking technologies.
  • Project Information: If you engage our services, we may collect information related to your project requirements, design preferences, and other specifications necessary for the development process.

2. How We Use Your Information

I use the collected information to:

  • Provide and manage our services, including responding to inquiries and completing projects.
  • Improve the functionality and user experience of our website.
  • Communicate with you about project updates, support, or any other relevant information.
  • Ensure the security and protection of our website and services.

I do not sell or rent your personal information to third parties. Your information will only be shared when necessary to fulfill your project requirements or comply with legal obligations.

3. Cookies and Tracking Technologies

My website uses cookies to enhance your browsing experience. Cookies help us understand how you use our website and allow me to offer personalized content or services. You can control or disable cookies through your browser settings, but please note that some features of our website may not function properly if cookies are disabled.

4. Data Security

I implement a variety of security measures to safeguard your personal and project-related information. While I strive to use commercially acceptable means to protect your data, no method of transmission over the internet is 100% secure. Therefore, we cannot guarantee its absolute security but work diligently to prevent unauthorized access.

5. Third-Party Services

I may use third-party tools or services to improve our website or deliver our services. These third parties may collect information about your interaction with my website. However, I ensure that any third-party services we use adhere to strict privacy and security standards.

6. Your Rights

You have the right to:

  • Request access to any personal information I hold about you.
  • Request corrections or updates to your personal information.
  • Request the deletion of your personal information from my records, subject to legal requirements.
  • Opt out of receiving marketing communications from me at any time.

To exercise these rights, please contact me using the information provided below.

7. Changes to the Privacy Policy

I may update this Privacy Policy from time to time to reflect changes in our practices or legal obligations. The updated policy will be posted on this page, and the effective date will be revised accordingly.

8. Contact Us

If you have any questions or concerns regarding this Privacy Policy or how we handle your data, please contact us at:

  • Email: me@mossawir.com
  • Phone: +92 333 2080504

By using my website and services, you agree to the terms of this Privacy Policy.

I take client confidentiality very seriously and am committed to maintaining the privacy and security of all information shared during our project. Below are the key principles I adhere to:

  1. Confidential Information
    Any information you provide, including business details, design specifications, proprietary data, or any other sensitive material, will be treated as strictly confidential.

  2. Non-Disclosure
    I will not disclose, share, or use any confidential information for any purpose outside the scope of your project. Information shared will be used solely for the purpose of delivering the services you've hired me for.

  3. Data Security
    All files, assets, and credentials will be stored securely, ensuring that no unauthorized third parties can access your information. Upon project completion, sensitive data will be properly stored or destroyed, as per our agreement.

  4. Third-Party Involvement
    If third-party collaboration is required, I will ensure that any partners or subcontractors adhere to the same confidentiality standards.

  5. Ownership of Work
    All project-related files, code, and design materials developed during the project remain your intellectual property, and no elements will be reused or shared without your consent.

  6. Post-Project Confidentiality
    Even after the project is completed, all confidential information shared will continue to be protected.