Jump to content
Search Community

Tween all boxes to the same position regardless of their initial position

eguneys test
Moderator Tag

Go to solution Solved by Diaco,

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I am trying to tween all boxes to { x: 10, y: 10 } coordinates, which is supposed to be the same position. But it doesn't work.

 

 

Why do these boxes go to offset of their starting positions as opposed to absolute coordinates. I need to transform them to specified coordinates no matter what their inital position is.

See the Pen LVVQqx by anon (@anon) on CodePen

Link to comment
Share on other sites

  • Solution

Hi eguneys :)

 

x,y properties are same as css translate , moves an element from its current position .

 

pls try this :

var box = $(".box");

// Tweens method :
for ( var i=0 ; i<box.length ; i++ ){
  TweenLite.to(box[i],1,{x:100-box[i].offsetLeft,y:100-box[i].offsetTop});
};

// Timeline method : 
var tl = new TimelineLite();
for ( var i=0 ; i<box.length ; i++ ){
  tl.to(box[i],1,{x:10-box[i].offsetLeft,y:10-box[i].offsetTop},0);
};
  • Like 4
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.
×
×
  • Create New...