Jump to content
Search Community

Tweening a className while overriding a property in that class

Mike D test
Moderator Tag

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,

 

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

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