Jump to content
Search Community

DowneyChow

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by DowneyChow

  1. 1 hour ago, GSAP Helper said:

    It's pretty tough to troubleshoot without a minimal demo - the issue could be caused by CSS, markup, a third party library, your browser, an external script that's totally unrelated to GSAP, etc. Would you please provide a very simple CodePen or CodeSandbox that demonstrates the issue? 

     

    Please don't include your whole project. Just some colored <div> elements and the GSAP code is best (avoid frameworks if possible). See if you can recreate the issue with as few dependancies as possible. If not, incrementally add code bit by bit until it breaks. Usually people solve their own issues during this process! If not, then at least we have a reduced test case which greatly increases your chances of getting a relevant answer.

     

    Here's a starter CodePen that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

     

     

    If you're using something like React/Next/Nuxt/Gatsby or some other framework, you may find CodeSandbox easier to use. 

     

    Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

    Thank you!

    This is the minimal demo  in CodeSandbox.

  2. Hello,guys! I am a designer and front-end green hands, learning Gsap and implementing some mouse-scrolling web animations in ReactJS.

    But it doesn't work when I use it. I hope to get your help. Thank you very much.

     

    I expect something similar to this example

     

     

    import "./styles.css";
    import { useRef, useEffect } from "react";
    import { gsap } from "gsap";
    import { ScrollTrigger } from "gsap/dist/ScrollTrigger";
    gsap.registerPlugin(ScrollTrigger);
    
    export default function App() {
      const containerRef = useRef();
      const pageRef = useRef();
      const Container = document.querySelectorAll(".container");
      console.log(Container);
    
      const Page = document.querySelectorAll(".page");
      console.log(Page);
    
      useEffect(() => {
        gsap.to(
          Page,
          {
            xPercent: -100 * (Page.length - 1),
            ease: "none",
            scrollTrigger: {
              trigger: ".container",
              pin: true,
              markers: true,
              end: () => "+=" + Container.offsetWidth
            }
          },
          []
        );
      });
    
      return (
        <div ref={containerRef} id="container" className="container">
          <div className="page" id="red" ref={pageRef}></div>
          <div className="page" id="green" ref={pageRef}></div>
          <div className="page" id="blue" ref={pageRef}></div>
          <div className="page" id="yellow" ref={pageRef}></div>
          <div className="page" id="pink" ref={pageRef}></div>
        </div>
      );
    }
    .App {
      font-family: sans-serif;
      text-align: center;
    }
    .page {
      width: 100vw;
      height: 100vh;
    }
    
    #red {
      background-color: rgb(202, 62, 62);
    }
    
    #green {
      background-color: green;
    }
    
    #yellow {
      background-color: yellow;
    }
    
    #blue {
      background-color: blue;
    }
    
    #pink {
      background-color: pink;
    }
    
    .container {
      display: flex;
      flex-shrink: 0;
      width: 500vw;
      flex-wrap: nowrap;
    }
    
    * {
      box-sizing: border-box;
      padding: 0;
      margin: 0;
    }

     

    See the Pen xxYpEOo by GreenSock (@GreenSock) on CodePen

×
×
  • Create New...