Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
bobby kc

GSAP Scale

Recommended Posts

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.

Link to post
Share on other sites

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×