fun Posted November 15, 2022 Share Posted November 15, 2022 Hello, I'm new to GSAP .. and I try to scrolling horizontally then pinning what I want when I reach yellow section pinned it then scroll to black div Thank you in advance See the Pen VwdzYdE by Mo2S (@Mo2S) on CodePen Link to comment Share on other sites More sharing options...
mvaneijgen Posted November 15, 2022 Share Posted November 15, 2022 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 2 Link to comment Share on other sites More sharing options...
fun Posted November 15, 2022 Author Share Posted November 15, 2022 not exactly .. I want the black div appeared on screen like this See the Pen KKpLdWW by GreenSock (@GreenSock) on CodePen Link to comment Share on other sites More sharing options...
Solution mvaneijgen Posted November 15, 2022 Solution Share Posted November 15, 2022 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 3 Link to comment Share on other sites More sharing options...
fun Posted November 15, 2022 Author Share Posted November 15, 2022 yea! that's exactly what I want... Thank you for your detailed explanation! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now