Jump to content
Search Community

Samalander

Members
  • Posts

    10
  • Joined

  • Last visited

Posts posted by Samalander

  1. How can I prevent this?

     

    Code:
     

    var timeline = gsap.timeline();
    const howItWorks = useRef();
    const s1 = useRef();
    const s2 = useRef();
    timeline.to(s1.current, {
          opacity: 0,
          y: -20,
          duration: 1,
        })
        .to(s2.current, {
          opacity: 1,
          y: -20,
          duration: 1,
        })
    
        ScrollTrigger.create({
          trigger: howItWorks.current,
          animation: timeline,
          start: "center center",
          end: "+=2000px",
          scrub: true,
          pin: true,
        }) 
    <section id={styles.howItWorks} ref={howItWorks}>
            <h2>How It <br/> Works</h2>
            <div className={styles.section} ref={s1}>
              <div>
                <h3>1</h3>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
              </div>
              <div id={styles.image}>
                <div/>
              </div>
            </div>
            <div className={styles.section} ref={s2}>
              <div>
                <h3>2</h3>
                <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
              </div>
              <div id={styles.image}>
                <div/>
              </div>
            </div>
          </section>

     

    next.js 12.2.0 

    react 18.2.0

    gsap 3.11.2

  2. 16 hours ago, GreenSock said:

    That error indicates that your timeline didn't have a ScrollTrigger applied to it at that point. Your code is only adding one if "normal" is truthy, so perhaps that was evaluating as false when your useEffect() ran. 

    So how could I fix this? I believe that the useEffect() function runs when React renders, and all of the GSAP stuff is inside of there because it only works after everything is rendered. This means that when I have an onclick function an element that needs to do GSAP stuff, it won't work because all of the elements get rendered before the GSAP stuff is run, so it will always generate an error.

  3. Beginner to GSAP so sorry if this is a stupid question - I have a section with an image inside of it. I'd like the section to pin, and the image to zoom in, stop, then zoom out and stop being pinned.

     

    I know how to pin it and make it zoom in, but I can't figure out how to make it zoom back out.

    https://imgur.com/8lYXybi <- Video of what I have so far

     

    Code:

    https://replit.com/@Samalander/compprof?embed=true (Click show files in the upper left)

     

    Thanks!

×
×
  • Create New...