mackao Posted February 1, 2021 Posted February 1, 2021 Hi, I'm a beginner for both js and gsap, but I have a idea about what I want to have I what to have a text rolling in the bottom of my site, and I found this answer from Mikel: This work perfect when the texts are about the same size The problem is that my is'nt I've found a lot of solutions for the loop, but all uses either a fixed width, or the width of the first element As you can see on my codepen, the text is removed to soon, when leaving on the left side Is this possible to fix? See the Pen xxRbMgW by mackao (@mackao) on CodePen.
ZachSaucier Posted February 1, 2021 Posted February 1, 2021 Hey mackao and welcome to the GreenSock forums. The issue is logical: How can you get the width of all of your texts? Since they differ you can't just get the width of one and multiply it by how many there are. There are two main approaches to getting the width: Positioning each of your elements in the same row (like display: inline-block with no wrapping or something similar), making sure the parent container has the full width of all of the children (i.e. is not restricted by the viewport's size). Then get the size of the container. Iterate through each of your elements, adding their width (and any spacing between them) together. Then after your iteration is done, you have the full width. Once you have the full width, you will need to adjust the wrapping logic to use that number instead. 2
Solution elegantseagulls Posted February 1, 2021 Solution Posted February 1, 2021 Another option would be just to duplicate your content and transform the whole container to -50% and just repeat that: See the Pen RwoPbdb by ryan_labar (@ryan_labar) on CodePen. 4
mackao Posted February 2, 2021 Author Posted February 2, 2021 I ended up using @elegantseagulls's solution, it was a good compromise for my case
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