Jump to content
GreenSock

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

clearProps on reverse()

Go to solution Solved by andyr,

Recommended Posts

Hello

 

I've got a modal which appears on a button click.  I use clearProps to remove inline styles.

tl.add(TweenLite.from('.ng_modal_dialog', 2, {left: "30%", backgroundColor: "red", clearProps: 'all'})); 

Then I do reverse().  Which adds them all back again. Can I clearProps after I've done reverse()?

 

Thank you.

Link to post
Share on other sites

Hi andyr  :)

 

pls try this : 

var anim = TweenMax.to('.mydiv',1,{x:200,backgroundColor:'blue'});

$("#backBtn").on("click", function(){
  anim.reverse().eventCallback("onReverseComplete", function(){ 
      TweenLite.set(this.target,{clearProps:'all'});
  });
});

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

  • Like 2
Link to post
Share on other sites

Thanks.

 

That clears the properties.  Now I need to hide and reset, so that the animation plays again from the start. 

 

Edit: I'll start a new thread, as the original request was solved.

Link to post
Share on other sites

I know this is answered expertly already by Diaco, especially for a single tween.

If you are using timelines, you can also put a set() at the beginning.

 

anim.set('.mydiv', {clearProps:"all"})
    .to('.mydiv',1,{x:200,backgroundColor:'blue'});


$("#back").on("click", function(){
  anim.reverse();
});

 

EDIT: http://codepen.io/GreenSock/pen/QbwaMO

  • Like 1
Link to post
Share on other sites
  • 2 years later...

Just a quick addendum to this. Is there any way to use clearProps and have it clear all GSAP traces from each element tweened in a timeline, without having to list every element separately that you want cleared? Thanks.

Link to post
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.

×