Jump to content
GreenSock

cmal

Reset inline "style" value when returned to default

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

I have the following TimelineLite animation:

tl
    .add(TweenLite.to(el, 0.1, {scale: 3.0}));
    .add(TweenLite.to(el, 0.3, {scale: 1.0, ease: Power2.easeInOut}));

As you can see, the animation ends by returning the scale to its original value. The problem is that the "scale" is still being set in the inline "style" in the HTML, and this is interfering with a CSS :hover state I have set.

 

So the question is: is there a way to have TweenLite intelligently remove any inline styles if the end value is equal to the original value? And if not, is there a good workaround for accomplishing the same thing?

Link to comment
Share on other sites

Hi,
 
Use clearProps like this:

tl
    .add(TweenLite.to(el, 0.1, {scale: 3.0}));
    .add(TweenLite.to(el, 0.3, {scale: 1.0, ease: Power2.easeInOut, clearProps:"scale"}));

You can read more about it here:

http://api.greensock.com/js/com/greensock/plugins/CSSPlugin.html

 

At the very bottom of the page.

 

Hope this helps,

Cheers,

Rodrigo.

  • Like 2
Link to comment
Share on other sites

@rhernando

 

Fast answer and exactly what I was looking for. You rock.

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