Jump to content
Search Community

horizontal scrolling then pinning

fun test
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts

Hi @fun welcome to the forum!

 

I just answered someones question and it kinda hits on the same notes I would want to say here, but instead of repeating my self, please read my comment here.  I think you'll find it really insight full. 

 

 

That said, Is this what you are looking for?

See the Pen ZERJBWa?editors=1010 by mvaneijgen (@mvaneijgen) on CodePen

  • Like 2
Link to comment
Share on other sites

  • Solution

I would make the black element also part of the container and have that one animate from the bottom. 

 

I have restructured your code a bit. The thing with GSAP (and ScrollTrigger) is that its really important how you layout your page with CSS. Personally I like to have all my elements in the correct position before I start animating. So I want them to be at the position when the animation should end.

 

For your pen I've layout out all the elements to be on top of each other in the .container div with position: absolute; Then in the timeline I only have to animate from some position, because the element is already at the end position. For the yellow this that isxPercent: 100 (eg 100% of the elements width) and the black yPercent: 100 (eg 100% of the elements height). Seems like this gets you the same result as the more complicated calculations in your pen. 

 

Hope it helps and happy tweening! 

 

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

  • Like 3
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...