Code icon

The App is Under a Quick Maintenance

We apologize for the inconvenience. Please come back later

Menu iconMenu iconFundamentals of Web Animation with GSAP
Fundamentals of Web Animation with GSAP

Chapter 7: Real-World Projects with GSAP

7.2 Project: Interactive Product Showcase

Objective: Develop an interactive product showcase for a fictional tech company's new product launch. The showcase will feature animations that respond to user interactions, highlighting different features of the product.

7.2.1 Project Breakdown

1. Project Concept

  • A landing page showcasing a new smartphone.
  • Animations to highlight features as the user scrolls.
  • Interactive elements that respond to user interaction, such as hover and click.

2. Tools and Resources

  • GSAP for animations.
  • ScrollTrigger plugin for scroll-based animations.
  • Basic HTML/CSS for webpage structure and styling.
  • SVG images or graphics for the smartphone and features.

3. Implementation Steps

  • Step 1: Webpage Structure
    • Create a basic HTML layout with a header, sections for each product feature, and a footer.
  • Step 2: Basic Styling
    • Use CSS to style the layout, focusing on a modern, clean design suitable for showcasing a tech product.
  • Step 3: Adding GSAP Animations
    • Implement GSAP animations for the header and feature sections. These could include the product image sliding in, text elements fading in, and feature icons animating into place.
  • Step 4: ScrollTrigger Integration
    • Use ScrollTrigger to activate animations as the user scrolls through different sections of the product features.
  • Step 5: Interactive Elements
    • Create interactive hover effects on feature icons or buttons, providing visual feedback to the user.

7.2.2 Example Code Snippets

HTML (Simplified Layout)

<div id="header">New Smartphone X</div>
<section id="feature1">Innovative Camera</section>
<section id="feature2">Long-lasting Battery</section>
<section id="feature3">Crystal Clear Display</section>

CSS (Basic Styling)

section {
  opacity: 0; /* Set up for GSAP animation */
  transform: translateY(50px);
}

JavaScript (GSAP with ScrollTrigger)

gsap.registerPlugin(ScrollTrigger);

gsap.to("#header", {duration: 1, opacity: 1, y: -20});

gsap.utils.toArray('section').forEach(section => {
  ScrollTrigger.create({
    trigger: section,
    start: "top 80%",
    onEnter: () => gsap.to(section, {opacity: 1, y: 0, duration: 1})
  });
});

Below is a complete HTML page that encapsulates the logic and structure for the "Interactive Product Showcase" project using GSAP and ScrollTrigger. This example will provide a foundational structure, which you can expand upon or modify according to your specific project needs.

7.2.3 Interactive Product Showcase HTML Page

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Interactive Product Showcase</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 0; padding: 0; }
        #header {
            text-align: center;
            padding: 50px;
            background-color: #f0f0f0;
            font-size: 2em;
        }
        section {
            opacity: 0;
            transform: translateY(50px);
            padding: 100px;
            text-align: center;
            font-size: 1.5em;
            background-color: #ffffff;
            border-bottom: 1px solid #ddd;
        }
        .feature { transition: transform 0.3s ease; }
        .feature:hover { transform: scale(1.1); }
    </style>
</head>
<body>

<div id="header">New Smartphone X</div>
<section id="feature1" class="feature">Innovative Camera</section>
<section id="feature2" class="feature">Long-lasting Battery</section>
<section id="feature3" class="feature">Crystal Clear Display</section>

<!-- GSAP Library -->
<script src="<https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js>"></script>
<!-- ScrollTrigger Plugin -->
<script src="<https://cdn.jsdelivr.net/npm/gsap@3/dist/ScrollTrigger.min.js>"></script>

<script>
    // Register the ScrollTrigger plugin
    gsap.registerPlugin(ScrollTrigger);

    // Animate the header
    gsap.to("#header", {duration: 1, opacity: 1, y: -20});

    // Animate each section on scroll
    gsap.utils.toArray('.feature').forEach(section => {
        ScrollTrigger.create({
            trigger: section,
            start: "top 80%",
            onEnter: () => gsap.to(section, {opacity: 1, y: 0, duration: 1})
        });
    });
</script>

</body>
</html>

Explanation of the Code

  • HTML Structure: The page contains a header and three sections representing different features of the product. Each section is styled to start with opacity: 0 and translated slightly down (transform: translateY(50px)) to set up for the animation.
  • Styling: Basic CSS is applied for a clean look, and a hover effect is added to each feature section for interactivity.
  • GSAP and ScrollTrigger: The GSAP library and ScrollTrigger plugin are included. The script at the bottom of the page initializes the animations. The header animates on page load, while the feature sections animate as they enter the viewport, based on the ScrollTrigger setup.

Customization and Expansion

This basic structure serves as a starting point for your project. You have the flexibility to customize and expand this project in various ways. For example, you can add more detailed styles to make it visually appealing. Consider incorporating images or SVGs of the product to provide a better understanding of its features.

Additionally, you can explore the option of including more complex animations or interactive elements to further enhance the user experience. By incorporating these enhancements, you can create a more immersive and engaging user interface that will leave a lasting impression on your users.

7.2 Project: Interactive Product Showcase

Objective: Develop an interactive product showcase for a fictional tech company's new product launch. The showcase will feature animations that respond to user interactions, highlighting different features of the product.

7.2.1 Project Breakdown

1. Project Concept

  • A landing page showcasing a new smartphone.
  • Animations to highlight features as the user scrolls.
  • Interactive elements that respond to user interaction, such as hover and click.

2. Tools and Resources

  • GSAP for animations.
  • ScrollTrigger plugin for scroll-based animations.
  • Basic HTML/CSS for webpage structure and styling.
  • SVG images or graphics for the smartphone and features.

3. Implementation Steps

  • Step 1: Webpage Structure
    • Create a basic HTML layout with a header, sections for each product feature, and a footer.
  • Step 2: Basic Styling
    • Use CSS to style the layout, focusing on a modern, clean design suitable for showcasing a tech product.
  • Step 3: Adding GSAP Animations
    • Implement GSAP animations for the header and feature sections. These could include the product image sliding in, text elements fading in, and feature icons animating into place.
  • Step 4: ScrollTrigger Integration
    • Use ScrollTrigger to activate animations as the user scrolls through different sections of the product features.
  • Step 5: Interactive Elements
    • Create interactive hover effects on feature icons or buttons, providing visual feedback to the user.

7.2.2 Example Code Snippets

HTML (Simplified Layout)

<div id="header">New Smartphone X</div>
<section id="feature1">Innovative Camera</section>
<section id="feature2">Long-lasting Battery</section>
<section id="feature3">Crystal Clear Display</section>

CSS (Basic Styling)

section {
  opacity: 0; /* Set up for GSAP animation */
  transform: translateY(50px);
}

JavaScript (GSAP with ScrollTrigger)

gsap.registerPlugin(ScrollTrigger);

gsap.to("#header", {duration: 1, opacity: 1, y: -20});

gsap.utils.toArray('section').forEach(section => {
  ScrollTrigger.create({
    trigger: section,
    start: "top 80%",
    onEnter: () => gsap.to(section, {opacity: 1, y: 0, duration: 1})
  });
});

Below is a complete HTML page that encapsulates the logic and structure for the "Interactive Product Showcase" project using GSAP and ScrollTrigger. This example will provide a foundational structure, which you can expand upon or modify according to your specific project needs.

7.2.3 Interactive Product Showcase HTML Page

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Interactive Product Showcase</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 0; padding: 0; }
        #header {
            text-align: center;
            padding: 50px;
            background-color: #f0f0f0;
            font-size: 2em;
        }
        section {
            opacity: 0;
            transform: translateY(50px);
            padding: 100px;
            text-align: center;
            font-size: 1.5em;
            background-color: #ffffff;
            border-bottom: 1px solid #ddd;
        }
        .feature { transition: transform 0.3s ease; }
        .feature:hover { transform: scale(1.1); }
    </style>
</head>
<body>

<div id="header">New Smartphone X</div>
<section id="feature1" class="feature">Innovative Camera</section>
<section id="feature2" class="feature">Long-lasting Battery</section>
<section id="feature3" class="feature">Crystal Clear Display</section>

<!-- GSAP Library -->
<script src="<https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js>"></script>
<!-- ScrollTrigger Plugin -->
<script src="<https://cdn.jsdelivr.net/npm/gsap@3/dist/ScrollTrigger.min.js>"></script>

<script>
    // Register the ScrollTrigger plugin
    gsap.registerPlugin(ScrollTrigger);

    // Animate the header
    gsap.to("#header", {duration: 1, opacity: 1, y: -20});

    // Animate each section on scroll
    gsap.utils.toArray('.feature').forEach(section => {
        ScrollTrigger.create({
            trigger: section,
            start: "top 80%",
            onEnter: () => gsap.to(section, {opacity: 1, y: 0, duration: 1})
        });
    });
</script>

</body>
</html>

Explanation of the Code

  • HTML Structure: The page contains a header and three sections representing different features of the product. Each section is styled to start with opacity: 0 and translated slightly down (transform: translateY(50px)) to set up for the animation.
  • Styling: Basic CSS is applied for a clean look, and a hover effect is added to each feature section for interactivity.
  • GSAP and ScrollTrigger: The GSAP library and ScrollTrigger plugin are included. The script at the bottom of the page initializes the animations. The header animates on page load, while the feature sections animate as they enter the viewport, based on the ScrollTrigger setup.

Customization and Expansion

This basic structure serves as a starting point for your project. You have the flexibility to customize and expand this project in various ways. For example, you can add more detailed styles to make it visually appealing. Consider incorporating images or SVGs of the product to provide a better understanding of its features.

Additionally, you can explore the option of including more complex animations or interactive elements to further enhance the user experience. By incorporating these enhancements, you can create a more immersive and engaging user interface that will leave a lasting impression on your users.

7.2 Project: Interactive Product Showcase

Objective: Develop an interactive product showcase for a fictional tech company's new product launch. The showcase will feature animations that respond to user interactions, highlighting different features of the product.

7.2.1 Project Breakdown

1. Project Concept

  • A landing page showcasing a new smartphone.
  • Animations to highlight features as the user scrolls.
  • Interactive elements that respond to user interaction, such as hover and click.

2. Tools and Resources

  • GSAP for animations.
  • ScrollTrigger plugin for scroll-based animations.
  • Basic HTML/CSS for webpage structure and styling.
  • SVG images or graphics for the smartphone and features.

3. Implementation Steps

  • Step 1: Webpage Structure
    • Create a basic HTML layout with a header, sections for each product feature, and a footer.
  • Step 2: Basic Styling
    • Use CSS to style the layout, focusing on a modern, clean design suitable for showcasing a tech product.
  • Step 3: Adding GSAP Animations
    • Implement GSAP animations for the header and feature sections. These could include the product image sliding in, text elements fading in, and feature icons animating into place.
  • Step 4: ScrollTrigger Integration
    • Use ScrollTrigger to activate animations as the user scrolls through different sections of the product features.
  • Step 5: Interactive Elements
    • Create interactive hover effects on feature icons or buttons, providing visual feedback to the user.

7.2.2 Example Code Snippets

HTML (Simplified Layout)

<div id="header">New Smartphone X</div>
<section id="feature1">Innovative Camera</section>
<section id="feature2">Long-lasting Battery</section>
<section id="feature3">Crystal Clear Display</section>

CSS (Basic Styling)

section {
  opacity: 0; /* Set up for GSAP animation */
  transform: translateY(50px);
}

JavaScript (GSAP with ScrollTrigger)

gsap.registerPlugin(ScrollTrigger);

gsap.to("#header", {duration: 1, opacity: 1, y: -20});

gsap.utils.toArray('section').forEach(section => {
  ScrollTrigger.create({
    trigger: section,
    start: "top 80%",
    onEnter: () => gsap.to(section, {opacity: 1, y: 0, duration: 1})
  });
});

Below is a complete HTML page that encapsulates the logic and structure for the "Interactive Product Showcase" project using GSAP and ScrollTrigger. This example will provide a foundational structure, which you can expand upon or modify according to your specific project needs.

7.2.3 Interactive Product Showcase HTML Page

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Interactive Product Showcase</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 0; padding: 0; }
        #header {
            text-align: center;
            padding: 50px;
            background-color: #f0f0f0;
            font-size: 2em;
        }
        section {
            opacity: 0;
            transform: translateY(50px);
            padding: 100px;
            text-align: center;
            font-size: 1.5em;
            background-color: #ffffff;
            border-bottom: 1px solid #ddd;
        }
        .feature { transition: transform 0.3s ease; }
        .feature:hover { transform: scale(1.1); }
    </style>
</head>
<body>

<div id="header">New Smartphone X</div>
<section id="feature1" class="feature">Innovative Camera</section>
<section id="feature2" class="feature">Long-lasting Battery</section>
<section id="feature3" class="feature">Crystal Clear Display</section>

<!-- GSAP Library -->
<script src="<https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js>"></script>
<!-- ScrollTrigger Plugin -->
<script src="<https://cdn.jsdelivr.net/npm/gsap@3/dist/ScrollTrigger.min.js>"></script>

<script>
    // Register the ScrollTrigger plugin
    gsap.registerPlugin(ScrollTrigger);

    // Animate the header
    gsap.to("#header", {duration: 1, opacity: 1, y: -20});

    // Animate each section on scroll
    gsap.utils.toArray('.feature').forEach(section => {
        ScrollTrigger.create({
            trigger: section,
            start: "top 80%",
            onEnter: () => gsap.to(section, {opacity: 1, y: 0, duration: 1})
        });
    });
</script>

</body>
</html>

Explanation of the Code

  • HTML Structure: The page contains a header and three sections representing different features of the product. Each section is styled to start with opacity: 0 and translated slightly down (transform: translateY(50px)) to set up for the animation.
  • Styling: Basic CSS is applied for a clean look, and a hover effect is added to each feature section for interactivity.
  • GSAP and ScrollTrigger: The GSAP library and ScrollTrigger plugin are included. The script at the bottom of the page initializes the animations. The header animates on page load, while the feature sections animate as they enter the viewport, based on the ScrollTrigger setup.

Customization and Expansion

This basic structure serves as a starting point for your project. You have the flexibility to customize and expand this project in various ways. For example, you can add more detailed styles to make it visually appealing. Consider incorporating images or SVGs of the product to provide a better understanding of its features.

Additionally, you can explore the option of including more complex animations or interactive elements to further enhance the user experience. By incorporating these enhancements, you can create a more immersive and engaging user interface that will leave a lasting impression on your users.

7.2 Project: Interactive Product Showcase

Objective: Develop an interactive product showcase for a fictional tech company's new product launch. The showcase will feature animations that respond to user interactions, highlighting different features of the product.

7.2.1 Project Breakdown

1. Project Concept

  • A landing page showcasing a new smartphone.
  • Animations to highlight features as the user scrolls.
  • Interactive elements that respond to user interaction, such as hover and click.

2. Tools and Resources

  • GSAP for animations.
  • ScrollTrigger plugin for scroll-based animations.
  • Basic HTML/CSS for webpage structure and styling.
  • SVG images or graphics for the smartphone and features.

3. Implementation Steps

  • Step 1: Webpage Structure
    • Create a basic HTML layout with a header, sections for each product feature, and a footer.
  • Step 2: Basic Styling
    • Use CSS to style the layout, focusing on a modern, clean design suitable for showcasing a tech product.
  • Step 3: Adding GSAP Animations
    • Implement GSAP animations for the header and feature sections. These could include the product image sliding in, text elements fading in, and feature icons animating into place.
  • Step 4: ScrollTrigger Integration
    • Use ScrollTrigger to activate animations as the user scrolls through different sections of the product features.
  • Step 5: Interactive Elements
    • Create interactive hover effects on feature icons or buttons, providing visual feedback to the user.

7.2.2 Example Code Snippets

HTML (Simplified Layout)

<div id="header">New Smartphone X</div>
<section id="feature1">Innovative Camera</section>
<section id="feature2">Long-lasting Battery</section>
<section id="feature3">Crystal Clear Display</section>

CSS (Basic Styling)

section {
  opacity: 0; /* Set up for GSAP animation */
  transform: translateY(50px);
}

JavaScript (GSAP with ScrollTrigger)

gsap.registerPlugin(ScrollTrigger);

gsap.to("#header", {duration: 1, opacity: 1, y: -20});

gsap.utils.toArray('section').forEach(section => {
  ScrollTrigger.create({
    trigger: section,
    start: "top 80%",
    onEnter: () => gsap.to(section, {opacity: 1, y: 0, duration: 1})
  });
});

Below is a complete HTML page that encapsulates the logic and structure for the "Interactive Product Showcase" project using GSAP and ScrollTrigger. This example will provide a foundational structure, which you can expand upon or modify according to your specific project needs.

7.2.3 Interactive Product Showcase HTML Page

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Interactive Product Showcase</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 0; padding: 0; }
        #header {
            text-align: center;
            padding: 50px;
            background-color: #f0f0f0;
            font-size: 2em;
        }
        section {
            opacity: 0;
            transform: translateY(50px);
            padding: 100px;
            text-align: center;
            font-size: 1.5em;
            background-color: #ffffff;
            border-bottom: 1px solid #ddd;
        }
        .feature { transition: transform 0.3s ease; }
        .feature:hover { transform: scale(1.1); }
    </style>
</head>
<body>

<div id="header">New Smartphone X</div>
<section id="feature1" class="feature">Innovative Camera</section>
<section id="feature2" class="feature">Long-lasting Battery</section>
<section id="feature3" class="feature">Crystal Clear Display</section>

<!-- GSAP Library -->
<script src="<https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js>"></script>
<!-- ScrollTrigger Plugin -->
<script src="<https://cdn.jsdelivr.net/npm/gsap@3/dist/ScrollTrigger.min.js>"></script>

<script>
    // Register the ScrollTrigger plugin
    gsap.registerPlugin(ScrollTrigger);

    // Animate the header
    gsap.to("#header", {duration: 1, opacity: 1, y: -20});

    // Animate each section on scroll
    gsap.utils.toArray('.feature').forEach(section => {
        ScrollTrigger.create({
            trigger: section,
            start: "top 80%",
            onEnter: () => gsap.to(section, {opacity: 1, y: 0, duration: 1})
        });
    });
</script>

</body>
</html>

Explanation of the Code

  • HTML Structure: The page contains a header and three sections representing different features of the product. Each section is styled to start with opacity: 0 and translated slightly down (transform: translateY(50px)) to set up for the animation.
  • Styling: Basic CSS is applied for a clean look, and a hover effect is added to each feature section for interactivity.
  • GSAP and ScrollTrigger: The GSAP library and ScrollTrigger plugin are included. The script at the bottom of the page initializes the animations. The header animates on page load, while the feature sections animate as they enter the viewport, based on the ScrollTrigger setup.

Customization and Expansion

This basic structure serves as a starting point for your project. You have the flexibility to customize and expand this project in various ways. For example, you can add more detailed styles to make it visually appealing. Consider incorporating images or SVGs of the product to provide a better understanding of its features.

Additionally, you can explore the option of including more complex animations or interactive elements to further enhance the user experience. By incorporating these enhancements, you can create a more immersive and engaging user interface that will leave a lasting impression on your users.