Jump to content
GreenSock

ferriss

Trigger on element with parallax

Go to solution Solved by ferriss,

Recommended Posts

Hi,

 

I couldn't find if there is something in the docs for this, but I have an element that has a basic transform parallax on it. That same element has a basic toggle class on it when it hits the top of the viewport, however, the makers on the this latter animation are wrong as it takes it from before the parallax.

 

I guess I need to offset it with the transform? But is this performant as the trigger point is constantly changing?

 

The two animations.

 

gsap.to(".js-pick-me-up", {
  ease: 'none',
  scrollTrigger: {
    trigger: ".block-intro",
    scrub: true,
    start: "top top",
    end: window.innerHeight,
  },
  y: window.innerHeight / 2
});

and

ScrollTrigger.create({
  trigger: ".js-pick-me-up",
  end: "bottom bottom",
  start: "top top",
  toggleClass: 'is-fixed'
});

Thanks

Link to comment
Share on other sites

Hey @ferriss,

 

I'm not really sure of timing or positioning from this code snippet, could you put together a minimal demo for us?

 

I'm sure I can recommend an alternative approach with the appropriate context!

 

Thanks

  

  • Like 1
Link to comment
Share on other sites

Also, for the record, ScrollSmoother has parallax effects baked in (data-speed) and they automatically integrate with ScrollTrigger so that the positions are adjusted according to the parallax movement. Super convenient!

 

https://greensock.com/scrollsmoother

 

Link to comment
Share on other sites

  • 2 weeks later...
  • Solution

I started doing an MVP and adding a wrapping div fixed my issue.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×