pattocheu Posted December 27, 2021 Share Posted December 27, 2021 Dear All, Hello to all, I would like to have some explanations about "Container Animation" seen in Gsap 3.8. In my Codepen demo, I can't scroll to the orange DIV and I don't understand what I am doing wrong. Thank you for your help. See the Pen LYzePeL by pattocheu (@pattocheu) on CodePen Link to comment Share on other sites More sharing options...
Solution akapowl Posted December 27, 2021 Solution Share Posted December 27, 2021 Hello there, @pattocheu First up, I would suggest taking a closer look on how flexbox handles things - e.g. if you want your sections to have specific widths, make sure to set the flex properties for them, or else flexbox will kind of do its own thing. https://css-tricks.com/snippets/css/a-guide-to-flexbox/#flex With that corrected, your tween will still not work because you have sections with different widths, so using xPercent with calculations based on the number of sections you have for where to tween things to won't work - those calculations you are using work for sections that all have the same width, filling the screen. As an alternative approach you could tween on the x instead and do your calculations based on the scrollWidth of the container and the clientWidth (or alternatively window.innerWidth). That works better already - Hope it helps See the Pen MWErygR by akapowl (@akapowl) on CodePen 3 Link to comment Share on other sites More sharing options...
pattocheu Posted December 27, 2021 Author Share Posted December 27, 2021 Hi @akapowl Thank you for your reply and the additional information. It is now clearer for me. 2 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