Jump to content
Search Community

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

Posted

HOw can i scale to a pixel  value. e.g. scale:"200px", this do not work, pls suggest how to zoom to a pixel value

thanks.

Posted

hello bobby kc, and Welcome to the GreenSock Forum!

 

This can be done by multiplying the scale factor by your elements width.

 

Example:

See the Pen gaqfs by jonathan (@jonathan) on CodePen.

 

If your element is:

  • 100px width .. and you want it to scale to 200px .. then it would be 100 x 2 = 200 (width x scale factor)
  • 50px width .. and you want it to scale to 200px .. then it would be 50 x 4 = 200 (width x scale factor)
var box1= document.getElementById("box1"),
    box2 = document.getElementById("box2");

// 100 x 2 = 200 (width x scale factor)
TweenMax.to(box1, 1.5,{scale:2, repeat:-1, yoyo:true});
// 50 x 4 = 200 (width x scale factor) .
TweenMax.to(box2, 1.5,{scale:4, repeat:-1, yoyo:true});

:

You would have to play with the scale factor to adjust to your needs by just using math

 

Hope this helps! :)

  • Like 1

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...