Share Posted March 17, 2015 Hello!1) div moves to 200 pixels to the right and takes the position 300px - it's ok2) and next div moves to 50 pixels to the left - why? I thought it was specified the absolute position (left:50px)And how I can move the block to the absolute position (left:50px) at the second tween (if the first tween use "x:..." ) var logo = document.getElementById("elem"); new TweenMax(logo, 2, {x:200}); new TweenMax(logo, 2, {css:{left:"50px"}}).delay(2); ...... <div style="left: 100px; top: 100px; position:absolute;" id="elem">blablabla</div> Link to comment Share on other sites More sharing options...
Share Posted March 17, 2015 Its going to be offset 200px in the second tween, so just undo it. var logo = document.getElementById("elem"); new TweenMax(logo, 2, { x: 200 }); new TweenMax(logo, 2, { x: 0, left: 50, delay: 2 }); 3 Link to comment Share on other sites More sharing options...
Share Posted March 18, 2015 Yup, Blake's solution is what you should use. This is just how CSS works when you combine transforms (x) and positions (left). Your div will end up at left:50, but also be transformed 200px to the right. Basically, what you are having GSAP do is this in CSS /*this div will be 250 px from left of window*/ .green { background-color:green; left:50px; -webkit-transform:translateX(200px); transform:translateX(200px); } which yields: http://codepen.io/anon/pen/VYVqKY?editors=010 3 Link to comment Share on other sites More sharing options...
Author Share Posted March 18, 2015 OSUblake, Carl - thank you! 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