Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Gary

Determine current value?

Recommended Posts

Is there a way to determine the current value of a property given the element, property, and position in the timeline?

 

I'd like to allow the user of my tool to add some custom animation at any give point, and have the animation use the current value as input.  For example, the width of an image might have changed earlier in the animation, or might even be in the middle of a tween.  I'd like to be able to read exactly what the current value of the width is at a particular time.

 

Possible? 

Link to comment
Share on other sites

 I'd like to be able to read exactly what the current value of the width is at a particular time.

 

 

As long as you know the element, time and property a function like this would work:

 

function getValues(element, time, property){
  tl.pause(time)
  
  $("#console").append("<br> requested property:" + property + " = " + element.style[property]);
  
  
  $("#console").append("<br><br> here are some more properties");
  $("#console").append("<br>left = " + element.style.left)
  //scale, rotation, x, y and others are in _gsTransform object on element
  $("#console").append("<br>rotation = " + element._gsTransform.rotation)
  //look in browser's js console to see all properties of _gsTransform object
  console.log(element._gsTransform);
}

 

http://codepen.io/GreenSock/pen/LoupF?editors=101

 

If you are trying to grab transform values like x, y, scaleX, rotationX etc, you will have to look for those in the elements, _gsTransform object.

  • Like 3
Link to comment
Share on other sites

Perfect!  Thanks, Carl.

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