Jump to content
Search Community

Tracing default Attributes like Opacity, Top and Left onUpdate (_gsTransform)

themepunch test
Moderator Tag

Go to solution Solved by Diaco,

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

Hi Guys,

 

I would like to trace the opacity / top / left attributes of an element during the Tween, how would i get the values the most effective way ?  

 

I know that transform attributes are written on the element with the object  tween.target._gsTransform however opacity, top and left attributes are not written within this object.

 

I would like to avoid to read on every update the css attribute and get values from there! 

 

Something like this:

var t = TweenLite.fromTo("#box", 1, {
  opacity: 0
}, {
  opacity: 1,
  onUpdate: getValue,
  onUpdateParams: ["{self}"]
});

function getValue(tween) {
  var element = tween.target;  
  /*jQuery('#trace').html("Trace:" + element._gsTransform.opacity);*/
}

Thanks a lot,

 

Krisztian from ThemePunch

Link to comment
Share on other sites

  • Solution

Hi themepunch  :)

 

pls try like this :

TweenLite.fromTo("#redBox",1,{opacity:0,left:0},{opacity:1,left:100,onUpdate:getValue});

function getValue() {
  var target = this.target[0];
  var tLeft = target.style["left"];
  var tOpacity = target.style["opacity"];
};

pls check this out : 

See the Pen KVzMQo by MAW (@MAW) on CodePen

  • Like 3
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.
×
×
  • Create New...