Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Mike D

Tweening a className while overriding a property in that class

Recommended Posts

Hi guys,

 

So I have a "default" class for an element that places it offscreen and ready to be animated in. I remove the "default" class in the tween which works just fine.

<style>
.myelement { left: 0px; }
.myelement.default { left: -200px }
</style>

TweenLite.to(".myelement",speed, { className: "-=default" });

Now, I have some scaling logic in place that is fired on resize. When resized, the "left" property is updated which now needs to overwrite the ".myelement" left value contained in the element's .myelement class.

TweenLite.to(".myelement",speed, { className: "-=default", left: "-300px" });

My guess is that the ".myelement" left value is overwriting the passed "left" parameter. Any suggestions on optimizing this is greatly appreciated.

 

 - Mike D

Link to comment
Share on other sites

Hello Mike..

 

Have you tried setting the left property to -300px after the class is removed, using the onComplete special property:

TweenLite.to(".myelement", speed, { className: "-=default",
        onComplete:function(){
                  TweenLite.set(".myelement", { left: "-300px" });
       }
});

See if that helps..

 

If not, can you please setup a limited

See the Pen by pen (@pen) on CodePen

or jsfiddle with an example of your issue..

 

thx :)

  • Like 2
Link to comment
Share on other sites

I'm not certain what the effect needs to look like, but splitting it into two tweens might work too:

TweenLite.to(".myelement", speed, { className: "-=default" });

// overwrites the left tween of the className tween
TweenLite.to(".myelement", speed, { left: "-300px" });
  • Like 1
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.
×