Jump to content
Search Community

skyfy

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by skyfy

  1. Hello,

     

    I must be missing something in this code, how can I set default values to have no animation on every load. Currently my header slides down on every page load.

    Any suggestions would great appreciated.

     

     useEffect(() => {
        if (typeof window !== `undefined`) {
          gsap.registerPlugin(ScrollTrigger)
          gsap.core.globals('ScrollTrigger', ScrollTrigger)
        }
        const showAnim = gsap
          .from(headerRef.current, {
            yPercent: -100,
            paused: true,
            duration: 1,
          })
          .progress(1)
        ScrollTrigger.create({
          id: 'navbar',
          start: 'top top',
          end: 99999,
          //   scrub: true,
          onUpdate: self => {
            return self.direction === -1 ? showAnim.play() : showAnim.reverse()
          },
        })
    
        return () => {}
      }, [])

     

  2. Hi Zach,

     

    I am struggling a bit with multiple trigger, attached code is what I am trying to  achieve, any guidance would be great.

    const Sticky = () => {
      const sectionOffset = `${sectionRef.current.offsetTop}`;
    
      if (!Killed) {
        // ScrollTrigger.saveStyles(stickyRef.current)
    
        // ScrollTrigger.config({ limitCallbacks: true })
    
        ScrollTrigger.matchMedia({
          "(max-width: 480x)": () => {
            ScrollTrigger.create({
              trigger: stickyRef.current,
              pin: true,
              start: `top-=${sectionOffset} top`,
              end: `bottom center-=${sectionOffset} `,
              markers: true,
              pinSpacing: false,
              scrub: 0.5,
              refresh: true,
            });
          },
    
          "(min-width: 768px)": () => {
            ScrollTrigger.create({
              trigger: stickyRef.current,
              pin: true,
              start: `top-=${sectionOffset} top`,
              end: `bottom center-=2%`,
              markers: true,
              pinSpacing: false,
              scrub: 0.5,
              refresh: true,
            });
          },
    
          "(min-width: 1024px)": () => {
            ScrollTrigger.create({
              trigger: stickyRef.current,
              pin: true,
              start: `top-=${sectionOffset} top`,
              end: `bottom center+=4%`,
              markers: true,
              pinSpacing: false,
              scrub: 0.5,
              refresh: true,
            });
          },
    
          "(min-width: 1200px)": () => {
            ScrollTrigger.create({
              trigger: stickyRef.current,
              pin: true,
              start: `top-=${sectionOffset} top`,
              end: "bottom center-=30%",
              markers: true,
              pinSpacing: false,
              // pinReparent: true,
              scrub: 1,
              // anticipatePin: 1,
            });
          },
        });
      }
    };

     

  3. Hello,

    Is there a solution to have  matchmedia ()  with multiple media queries for scroll trigger, any suggestions would be great.

     

     

    ScrollTrigger.matchMedia({
    '(min-width: 768px)': ( ) {
     
    }
    '(min-width: 1024px)': ( ) {
     
    }
    '(min-width: 1200px)': ( ) {
     
    }
    '(min-width: 1600px)': ( ) {
     
    }
    })
     
     
     
     
  4. Hello again, 

     

    we have found the solution,  primarily when you pin the entire element is placed outside the component. We had background  and text colors changing dynamically on scroll, this caused colors to freeze when pinned, for which we used theme provider  global context to pass  the colors now it works even outside the component. We will try and share minimal working file at the earliest.

    much appreciate the support

    cheers

  5. Thank you again for the support,

     

    current edition initializes on first scroll, and its skips the pinning.

     

    We are setting the theme which has transition duration,  if we set the pin on load it freezes the initial colors of the pinnned element,.

    pinning has to trigger right after transition. completion.

     

    can we have an absolute top value , currently we have set the value manually, ?

     

     

    start: 'top-=14% top',
              
  6. Hello, We finally tracked the problem with our css styling, we are facing a minor issue with scrolltrigger.

     

    How to approach delay of scroll trigger on load. below is the code which we are using in Gatsby. 

     

     we want to set color first and wait for animation to complete and set sticky mode else stickymode inherits orginal colors.

     any suggestions would be great help.

    useEffect(() => {
      if (titleRef.current == null) return
      if (typeof window !== `undefined`) {
        gsap.registerPlugin(ScrollTrigger)
        gsap.core.globals('ScrollTrigger', ScrollTrigger)
      }
    
      const intro = () => {
        const introTL = gsap.timeline()
        introTL.to('html', 0, {
          css: { visibility: 'visible' },
        })
      }
      const ToggleColor = () => {
        const toggleColorTL = gsap.timeline()
        toggleColorTL.from('html', {
          duration: 0.01,
          scrollTrigger: {
            trigger: toggleColorRef.current,
            start: 'top-=15% top',
            end: 'bottom top+=10%',
            toggleAction: 'play reset reset reset ',
            markers: true,
            scrub: 0.1,
          },
          '--text-color': 'var(--accent)',
          '--background-color': 'var(--dark)',
        })
      }
      const Sticky = () => {
        ScrollTrigger.saveStyles(titleRef.current)
        ScrollTrigger.matchMedia({
          '(max-width: 1199px)': () => {
            ScrollTrigger.create({
              trigger: titleRef.current,
              pin: true,
              start: 'top-=14% top',
              end: 'bottom center-=2%',
              // markers: true,
              pinSpacing: false,
              pinReparent: true,
              // scrub: 0.5,
              // pinType: 'fixed',
              anticipatePin: 1,
              // refreshPriority: -1,
            })
          },
          '(min-width: 1200px)': () => {
            ScrollTrigger.create({
              trigger: titleRef.current,
              pin: true,
              start: 'top-=13.5% top',
              end: 'bottom center-=35%',
              markers: true,
              pinSpacing: false,
              pinReparent: true,
              scrub: 0.5,
              // refreshPriority: -1,
              // pinType: 'fixed',
              anticipatePin: 1,
            })
          },
        })
        ScrollTrigger.refresh(true)
      }
      const master = gsap.timeline()
      master.add(ToggleColor()).add(intro(), '+=2').call(Sticky())
    }, [])

     

  7. Hello,

     

    Sorry for intruding into this thread, I tried similar approach in Gatsby , some reason it's not working . Below is the use effect code I tried to make it work. Any suggestion would be greatly appreciated.  

    cheers -ak

     

    useEffect(() => {
    gsap.registerPlugin(ScrollTrigger)
    const tl = gsap.timeline({
    paused: true,
    scrollTrigger: {
    trigger: titleRef.current,
    pin: true,
    start: 'top top',
    scrub: true,
    markers: true,
    pinSpacing: false,
    },
    })
    }, [])
×
×
  • Create New...