paro Posted May 5, 2022 Share Posted May 5, 2022 I ran into a new problem while working on my previous topic. I want the two boxes moving from top to bottom and bottom to top to always move vertically towards the exact center even if the screen size changes. Some calculations are needed here, but I couldn't find which variable I can use to calculate it. I mean, even if the screen height changes, the moving objects will be above and below the middle text. See the Pen GRQJGvZ by tw_parodia (@tw_parodia) on CodePen Link to comment Share on other sites More sharing options...
Solution PointC Posted May 5, 2022 Solution Share Posted May 5, 2022 I'm not sure I follow the question. Do you mean you want the "Hello" and "World" boxes to land perfectly centered on the "Random Text" box? See the Pen a50267e21cfa1e8397e995a7c19ba96f by PointC (@PointC) on CodePen Is that what you meant? 1 1 Link to comment Share on other sites More sharing options...
paro Posted May 5, 2022 Author Share Posted May 5, 2022 Thank you again @PointC. I learned new thinks again, that "yPercent" looks super cool. This line solved my issue; yPercent: gsap.utils.wrap([-150, 150]), 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