Share Posted March 1, 2016 hello everyone, i'm wondering how can i centering my svg object exactly in the center of the screen. I give a style for my svg like position: absolute, top:0,left:50%, transform: translate(0,-50%). how can i move it to the center of the screen with gsap? Link to comment Share on other sites More sharing options...
Share Posted March 1, 2016 Hi and welcome to the GreenSock forums. I think its best to just let GSAP handle the translation and positioning like so TweenMax.to("svg", 1, {left:"50%", top:"50%", yPercent:-50, xPercent:-50}); http://codepen.io/GreenSock/pen/LNEjrG Read more about xPercent and yPercent: http://greensock.com/gsap-1-13-1 In the future please consider providing a CodePen demo as it helps us better understand the issue. Thanks Link to comment Share on other sites More sharing options...
Author Share Posted March 1, 2016 many thanks for the answer carl. sure, i will provide a codepen demo for the next question. Link to comment Share on other sites More sharing options...
Share Posted March 1, 2016 Hi and welcome to the GreenSock forums. I think its best to just let GSAP handle the translation and positioning like so TweenMax.to("svg", 1, {left:"50%", top:"50%", yPercent:-50, xPercent:-50}); See the Pen LNEjrG by GreenSock (@GreenSock) on CodePen Read more about xPercent and yPercent: http://greensock.com/gsap-1-13-1 In the future please consider providing a CodePen demo as it helps us better understand the issue. Thanks I was having issues with the arcs going off the page when rotating. I finally just changed the viewBox in the SVG. So would it be better to let GSAP do this? Also for scaling? See the Pen eZmzKM?editors=1100 by RhinoRudi (@RhinoRudi) on CodePen Thanks 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