Jump to content
Search Community

gsap sticky

Yuliya92 test
Moderator Tag

Recommended Posts

Your end trigger was already done before it started, so nothing would happen. You can see this with the markers if the green once touch they start and if the red once touch it ends. 

 

I've changed some of your logic around. Instead of using the .balon element as the trigger I use the .product element, then we don't need to do weird calculations (-142px) on that and can just start at the top. My advice would be use the named trigger eg top and bottom or use % based values, but don't mix them (0% = top 100% = bottom).

 

Then instead of setting pin: true, you can set pin to the element you want to pin, in this case .balon, then the only thing we need to calculate is when .balon needs to stop pinning. We know we want the bottom of .balon to touch the bottom of the element, so we need the height of it and .balon is offset a bit from .product, so we need to know that distance (that is your -142px, but better to calculate that, so it is responsive). So that is what we do in the end trigger. 

 

Hope it helps and happy tweening! 

 

See the Pen OJrqXaK?editors=0010 by mvaneijgen (@mvaneijgen) on CodePen

  • Like 2
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.
×
×
  • Create New...