Jump to content
Search Community

Stacking Cards: translate Y - Keep cards in postion when reaching the end pin

equionx94 test
Moderator Tag

Go to solution Solved by ryan_labar,

Recommended Posts

Everything works perfectly, until i add in: gsap.to(card, { y: -progress * 25 });

 

The Y translate gets overwritten when I reach the end-pins trigger. Is there a way to keep the Y translate position after reaching the end-pin or some other way of doing this? I want to keep the cards stacked on top of each other as you scroll past the end-pin.

 

If you comment out the gsap.to(card, { y: -progress * 25 }); that is how I want everything to act, but I want the cards to move upwards slightly as you scroll too.

See the Pen LYaWYpE by enox94 (@enox94) on CodePen

Link to comment
Share on other sites

  • Solution

Yes, translating the y value here is causing the wires to get a bit crossed. You could consider using yPercent to avoid this: gsap.to(card, { yPercent: -progress * 6.25 })

I got the 6.25 value by: (desired y value) / (card height) * 100 to get the percentage. 25/400*100.

  • Like 1
Link to comment
Share on other sites

24 minutes ago, ryan_labar said:

Yes, translating the y value here is causing the wires to get a bit crossed. You could consider using yPercent to avoid this: gsap.to(card, { yPercent: -progress * 6.25 })

I got the 6.25 value by: (desired y value) / (card height) * 100 to get the percentage. 25/400*100.

Thank you so much!

Link to comment
Share on other sites

On 1/16/2024 at 12:23 PM, ryan_labar said:

Yes, translating the y value here is causing the wires to get a bit crossed. You could consider using yPercent to avoid this: gsap.to(card, { yPercent: -progress * 6.25 })

I got the 6.25 value by: (desired y value) / (card height) * 100 to get the percentage. 25/400*100.

Thanks so much for this again, but just noticed that when I reach the end/re-enter the pinned section, the cards transform resets to 0, and re animates back. You can see what I mean in the code pen if you scroll back and forth between the end-pin marker on card 1 and 2.

 

I've looked up docs on how to reverse an animation to no solution, but I'm not sure if that's what I want here.

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...