Logo

dev-resources.site

for different kinds of informations.

"Day 7 with GSAP: Interactive Scrolling Animation with Rotating Arrows"

Published at
12/15/2024
Categories
gsap
javascript
beginners
tutorial
Author
anticoder03
Author
11 person written this
anticoder03
open
"Day 7 with GSAP: Interactive Scrolling Animation with Rotating Arrows"

Introduction

๐Ÿ‘‹ Hello Developers!

Welcome to Day 7 of my GSAP Journey, where I explore the infinite possibilities of animations on the web. Today, I took on the challenge of creating an interactive scroll-based marquee animation featuring dynamic text and rotating arrows.

With GSAP's powerful animation tools, weโ€™ll make the page respond to user scroll directionโ€”up or downโ€”with seamless movement and rotation. Letโ€™s dive in!


What Weโ€™re Building ๐Ÿ› ๏ธ

Our animation will include:

  • A scrolling marquee of text and images.
  • Responsive animations that adjust based on the scroll direction.
  • Rotating arrows to add flair!

You can view the live demo here.


HTML Structure

Hereโ€™s the simple HTML markup I used:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Day-7 Scrolling Text Animation</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div id="page1"></div>
    <div id="page2">
        <div id="move">
            <div class="marque">
                <h1>Ashish Prajapati</h1>
                <img src="https://www.brandium.nl/wp-content/uploads/2023/07/arrow-br.svg" alt="arrow">
            </div>
            <div class="marque">
                <h1>Ashish Prajapati</h1>
                <img src="https://www.brandium.nl/wp-content/uploads/2023/07/arrow-br.svg" alt="arrow">
            </div>
        </div>
    </div>
    <div id="page3"></div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"></script>
<script src="script.js"></script>
</html>
Enter fullscreen mode Exit fullscreen mode


JavaScript Animation with GSAP

Hereโ€™s the GSAP-powered JavaScript code that makes the magic happen:

window.addEventListener("wheel", function (dets) { 
    if (dets.deltaY > 0) {
        // Scrolling Down
        gsap.to(".marque", {
            x: "-200%", 
            duration: 4,
            repeat: -1, 
            ease: "none", 
        });
        gsap.to(".marque img", {
            rotate: 180
        });
    } else {
        // Scrolling Up
        gsap.to(".marque", {
            x: "0%", 
            duration: 4,
            repeat: -1, 
            ease: "none", 
        });
        gsap.to(".marque img", {
            rotate: 0
        });
    }
});
Enter fullscreen mode Exit fullscreen mode

How It Works โš™๏ธ

  1. Event Listener: The window.addEventListener("wheel") detects the scroll direction.
  2. GSAP Animations:
    • gsap.to() moves the marquee in a specific direction.
    • The rotation of arrows adds a dynamic, interactive feel.
  3. Infinite Scrolling: Using repeat: -1 ensures the marquee keeps looping endlessly.

Challenges & Learnings

๐Ÿ’ก Challenge: Synchronizing the scroll direction with marquee movement was tricky.

๐ŸŽฏ Solution: GSAPโ€™s robust API made it easy to fine-tune the animations with properties like repeat, ease, and duration.


Final Thoughts

This project showed how GSAP can handle scroll-based interactions and bring webpages to life. Whether youโ€™re working on a personal portfolio or a creative website, GSAP is the perfect tool to make animations engaging and intuitive.

๐Ÿš€ Try it yourself and share your creations!


Resources


gsap Article's
30 articles in total
Favicon
How to improve the Frontend part of the project using one button as an example :))))
Favicon
Reflections on My Coding Journey: Lessons from Recent Weeks
Favicon
Circle Cursor Js #GSAP
Favicon
"Day 7 with GSAP: Interactive Scrolling Animation with Rotating Arrows"
Favicon
GSAP ScrollTrigger animation for Upwork Client Demo
Favicon
Day 6: Text Animation with GSAP โ€“ A Split Letter Magic! ๐ŸŽจโœจ
Favicon
๐Ÿš€ Day 5: Creating a Hamburger Menu with GSAP
Favicon
Day 4: Enhancing UX with a Custom Cursor Using GSAP ๐Ÿš€๐ŸŽจ
Favicon
"Unlocking the Power of GSAP for Stunning Web Animations" ๐ŸŽจโœจ
Favicon
Preloader Animation #GSAP
Favicon
GSAP: GreenSock Animation Platform ๐Ÿš€
Favicon
Animated Carousel
Favicon
๐Ÿš€ ๐—ง๐—ต๐—ฒ๐—ฅ๐—ฒ๐—ฎ๐—น๐—›๐—ผ๐˜๐—ฒ๐—น๐˜€ ๐ŸŒŸ
Favicon
Clip-Path Circle Reveal Animation With Mouse Movement
Favicon
Getting started with Gsap!
Favicon
Todayโ€™s new knowledge #7(GSAP)
Favicon
Image Reveal Animation with HTML, CSS, and GSAP
Favicon
Easy React Animation with GSAP
Favicon
MoonAlert A CSS Animated Moon Notification Box
Favicon
Creating a Mesmerizing Moonlit Night Sky Animation with CSS
Favicon
๐Ÿš€ Motion Scape With GSAP
Favicon
Pinning Images with GSAP: A Smooth Scrolling Animation in Next.js
Favicon
Learning GSAP with a Day-to-Night Scroll Animation ๐ŸŒž๐ŸŒœ
Favicon
From Static to Stunning: Animate with GSAP
Favicon
Blurry Card with Parallax Effect ๐Ÿ’ณ
Favicon
Fun Animation using GSAP
Favicon
Future Bank Fintech Green: The Intersection of Finance and Sustainabilit
Favicon
Framer ground.
Favicon
Parallax image scroll speed with Nuxt 3 and GSAP ๐Ÿ›ฃ๏ธโœจ
Favicon
Creating Interactive Hover Effects with GSAP and SplitType

Featured ones: