Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
Noahdecoco

Get width after scale

Recommended Posts

Hi,

 

How can I get the actual width of an element after scaling it with Tweenmax?

 

Example:

$('#myDiv').width(100); // Sets width of #myDiv to 100;

TweenMax.set($('#myDiv'), {scale:1.2});

console.log($('#myDiv').width()); // gives 100 instead of 120

How can I get the actual width of the div?

 

Thanks a lot in advance, this thing is frustrating me and breaking my head today...

 

 

Link to post
Share on other sites

Hi

 

The issue is that width an scale work on different levels.

 

Think of scale like A magnifying glass, sure the element looks bigger but the actual size is still the same. What you could do is multiply the scale for the element's width and you'll get the magnified width so to speak.

 

Hope this helps

Cheers

Rodrigo

Link to post
Share on other sites

Hi and welcome to forums;

 

Actually when you use scale the engine tweens not the width and height, but the CSS3 transform ( the transform matrix ) of the object. The final style will be something like "z-index: 0; -webkit-transform: matrix(1.2, 0, 0, 1.2, 0, 0); " and the width and the height will stay the same, since the CSS3 transforms are different then the css width and height properties.  Like Rodrigo pointed out, if you need to know the width and height of the element (how big they seem), you just have to multiply width and height by the scale factor.

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×