Search Community

# Coordinates, scale and rotation

Moderator Tag

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

Hello,

My question with this example :

See the Pen umFdy by NicolasJ (@NicolasJ) on CodePen

How to ensure that when "Center" is unchecked and click on the button "DO IT 2" the red block is positioned correctly. That is to say that the two upper corners are aligned and the result is displayed [t = 0 | b = 290 | l = 0 | r = 50] and not [55 t = | b = 235 | s = 55 | r = 5]

How to ensure that when "Center" is checked and click on the "DO IT 3" button the red block is centered on the gray block?

In summary, my question is how to properly calculate the sets of coordinates which I want to go in both cases (centered checked and unchecked) and keeping transformOrigin:"50% 50%".

Hoping to be sufficiently clear

Thanks

##### Share on other sites

Based on your example, and what I think you're trying to do, I would change the scale on your doIt3, and doIt4 functions to this

```function doIt3() {
init();
centerX = (useCenter ? (containerW - blocW * scale/2) / 2 : 0);
centerY = (useCenter ? (containerH - blocH * scale/2) / 2 : 0);
TweenLite.to(bloc, 1, {rotation:0,  x:centerX, y:centerY, scale:scale, transformOrigin:"50% 50%", onComplete:function() {logResult()}});
}```

Hopefully that helps you get closer to what you're trying to do.

##### Share on other sites

Thanks, I update the pen ..

but this solution does not work if you try another scale value, for example 3

##### Share on other sites

Pen updated.

I think that the solustion for DoIt3 is

```centerX = (useCenter ? (containerW - blocW * scale) / 2 -(blocW - blocW*scale)/2: -(blocW - blocW*scale)/2);
centerY = (useCenter ? (containerH - blocH * scale) / 2 -(blocH - blocH*scale)/2: -(blocH - blocH*scale)/2);```

Due to the fact that the scale is from the center of the object