Close Menu
Trendswave MediaTrendswave Media
  • Home
  • About Us
    • Contact Us
  • Services
  • Influencer Marketing
  • Marketing
  • SEO
  • Social Media
  • Web Design
  • Shop

Subscribe to Updates

Get the latest creative news from Trendswave about Marketing, SEO & Web Design.

Please enable JavaScript in your browser to complete this form.
Loading
What's Hot

Driving Qualified Leads With LinkedIn Content: A Proven Formula

October 3, 2025

Google Ads copywriting with AI: Getting the prompt right

October 3, 2025

A Practical Guide To Building With Clarity (Part 2) — Smashing Magazine

October 3, 2025
Facebook X (Twitter) Instagram
Trendswave MediaTrendswave Media
  • Home
  • About Us
    • Contact Us
  • Services
  • Influencer Marketing
  • Marketing
  • SEO
  • Social Media
  • Web Design
  • Shop
Trendswave MediaTrendswave Media
Home»Web Design»How to build horizontal marquee effects with GSAP
Web Design

How to build horizontal marquee effects with GSAP

adminBy adminJanuary 13, 2025No Comments4 Mins Read
Facebook Twitter Pinterest LinkedIn Tumblr WhatsApp VKontakte Email
How to build horizontal marquee effects with GSAP
Share
Facebook Twitter LinkedIn Pinterest Email


New to GSAP?

First things first: did you get here ’cause you’re curious about GSAP, but don’t know exactly what it is? Let’s give it a quick overview.

So, what is GSAP?

GSAP is a JavaScript animation library from GreenSock. You can create high-quality GSAP animations. These will perform well in every browser you’re using.

There are also GSAP plugins that will help you achieve more, by expanding the GSAP library capabilities.

Previous GSAP tutorials

In the past, I’ve shown you how to use GSAP to build different effects. From cursor hovers and a page loading GSAP animation to a draggable image gallery.

The process

You can certainly create a marquee effect in CSS only by animating the transform property. However, in this tutorial, we’ll discuss how to build them using GSAP. This way, we can take advantage of all the extra goodies of this library.

In its simplest form, all we need to create marquees with GSAP are the horizontalLoop() and verticalLoop() helper functions.

In our case, we’ll only focus on horizontal GSAP marquee animations as they’re more popular.

It’s worth noting that a horizontal marquee brings many accessibility challenges. Moving text can be distracting and difficult to read. Consider carefully the kind of content you wish to display in this way!

Basic horizontal marquee

In the most straightforward implementation, consider the following demo. We’ll infinitely animate some logos:

The required JavaScript marquee code is as follows:

1
window.addEventListener("load", function () {
2
  horizontalLoop(".marquee-item", {
3
    repeat: -1,
4
    paddingRight: 40,
5
    speed: 0.5,
6
  });
7
});

Let’s pay attention to the paddingRight configuration property. We use a value that matches the gap (40px) between the GSAP marquee items.

We do this to prevent the overlapping between the first and last elements. Also, to give them a space that matches the other elements. That said, if you put paddingRight: 0, you’ll end up with this result:

The layout if we put don't put paddingRightThe layout if we put don't put paddingRightThe layout if we put don't put paddingRight

Horizontal marquee with stops

In this case, each marquee item contains the same text and a Lottie animation. To avoid bloating our HTML, we generate the horizontal marquee items using JavaScript. In a real-world scenario, we can also put ARIA attributes to improve the accessibility.

Each time we hover over an item, the HTML marquee effect pauses. To achieve this, we use the pause() and play() methods that are available to a GSAP timeline. Scroll down to the footer in this demo to see the effect:

Horizontal marquees with reversed directions

Let’s now work on a more complicated example. Consider the following demo. In this one, we have two horizontal marquee effects that run in opposite directions:

Their direction is determined by the value of the data-reversed HTML attribute.

So, what makes this demo interesting? We use GSAP’s matchmedia() method to apply different paddingRight and speed property values depending on the screen size. Be sure to test it by resizing your browser window.

Play horizontal marquees when in view

In the following demo, we put GSAP’s ScrollTrigger plugin into play. We play the marquees only when they are in view. This way we do our best to ensure that the site visitors will see all our animated items. 

Again, use your browser inspector to test how the GSAP animations stop when the related html marquee exits the viewport.

Horizontal marquee like slider

In this example, our marquee behaves like a slider. It autoplays, and there are arrows for navigating back and forth.

Additionally, we use GSAP’s Draggable plugin to enable drag functionality. This happens by passing the draggable: true configuration property to the horizontalLoop() function.  

As a bonus, the HTML marquee stops each time we hover over an image. At that moment, its corresponding overlay appears with a slide GSAP animation. 

Once again, resize your browser window to test how the layout changes.

There you go, GSAP guru!

Hopefully, you enjoyed the GSAP marquees we built. Now you have enough knowledge and inspiration to start building your own.

On the other hand, if you’d like to try professionally designed web templates to save you some time, try out an Envato subscription. It gives you access to millions of high-quality creative assets that you can use to improve your site.

Last but not least, I have added all the demos of this tutorial to a CodePen Collection. Be sure to check it out and give it some love!

As always, thanks a lot for reading!



Source link

Build Effects GSAP horizontal marquee
Share. Facebook Twitter Pinterest LinkedIn Tumblr WhatsApp Email
Previous ArticleInstagram Bots Unveiled: Balancing Automation with Authentic Engagement for Growth
Next Article How To Rank On Google’s AI Overviews
admin
  • Website

Related Posts

A Practical Guide To Building With Clarity (Part 2) — Smashing Magazine

October 3, 2025

Fresh Resources for Web Designers and Developers (September 2025)

October 2, 2025

Shades Of October (2025 Wallpapers Edition) — Smashing Magazine

October 1, 2025

Principles And Implementation (Part 1) — Smashing Magazine

September 29, 2025
Leave A Reply Cancel Reply

  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
  • Vimeo
Don't Miss
Marketing

Driving Qualified Leads With LinkedIn Content: A Proven Formula

By adminOctober 3, 20250

Are you struggling to generate qualified leads from your LinkedIn content? Wondering how to transform…

Google Ads copywriting with AI: Getting the prompt right

October 3, 2025

A Practical Guide To Building With Clarity (Part 2) — Smashing Magazine

October 3, 2025

Meta unveils Business AI and new generative tools

October 2, 2025

Subscribe to Updates

Get the latest creative news from Trendswave about Marketing, SEO & Web Design.

Please enable JavaScript in your browser to complete this form.
Loading
About Us

Trendswave is an Influencer Marketing Agency with access to one of the largest influencer networks in the Poland, connecting brands and agencies to only the best influencers and social media thought leaders.

Our Picks

Driving Qualified Leads With LinkedIn Content: A Proven Formula

October 3, 2025

Google Ads copywriting with AI: Getting the prompt right

October 3, 2025
Quicklinks
  • Influencer Marketing
  • Marketing
  • SEO
  • Social Media
  • Web Design
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions
© 2025 Trendswave.All Rights Reserved

Type above and press Enter to search. Press Esc to cancel.