Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
mrborgen

How to I tween an object to a top/left position on the page, relative to the viewport/body?

Recommended Posts

I'm trying to get the target to tween/animate to a position relative to the viewport or body (or parent element), rather than relative to the element itself. How can I do this? When I run the following code, it Tweens the element (target) to a position relative to its own starting position.  

 

    TweenLite.to(target, 0.5, { top: '200px', left: '200px'})

 

 

Link to comment
Share on other sites

Also, be sure that your absolutely positioned element is not a child of a relatively or absolutely positioned element (unless that element is the size of the viewport).

 

See the Pen OVJpbm by sgorneau (@sgorneau) on CodePen

  • Like 2
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×