Jump to content
GreenSock

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

How to Trigger from a JS-validate?

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'm trying to customize my Mailchimp validation

 

Upon successful form validation, a 'thank you/almost finished' overlay is revealed with .show(), but i wanted to animate how it appears with GSAP.

 

How can I call/trigger a GSAP animation from this mc-validate.js ?

if (resp.result == "success"){
       $('#mce-'+resp.result+'-response').show();
       $('#mce-'+resp.result+'-response').css({"width": "80%", "padding": "3% 5%"});
       $('#mc-embedded-subscribe-form').each(function(){
           this.reset();
       });
});
Thanks so much.

Share this post


Link to post
Share on other sites

Hello , and Welcome to the GreenSock forum!

 

Try this:

if (resp.result == "success"){
       TweenMax.set('#mce-'+resp.result+'-response', {autoAlpha:0});
       TweenMax.to('#mce-'+resp.result+'-response', 0.4, {autoAlpha:1});
       TweenMax.to('#mce-'+resp.result+'-response', 0.5, {"width": "80%", "padding": "3% 5%"});
       
       $('#mc-embedded-subscribe-form').each(function(){
           this.reset();
       });
});

Above I use the autoAlpha property of GSAP to animate a fade.

 

autoAlpha is part of the GSAP CSSPlugin: http://greensock.com/docs/#/HTML5/GSAP/Plugins/CSSPlugin/

  • autoAlpha
    Identical to opacity except that when the value hits 0 the visibility property will be set to "hidden" in order to improve browser rendering performance and prevent clicks/interactivity on the target. When the value is anything other than 0, visibility will be set to "inherit". It is not set to "visible" in order to honor inheritance (imagine the parent element is hidden - setting the child to visible explicitly would cause it to appear when that's probably not what was intended). And for convenience, if the element's visibility is initially set to "hidden" and opacity is 1, it will assume opacity should also start at 0. This makes it simple to start things out on your page as invisible (set your css visibility:hidden) and then fade them in whenever you want.
//fade out and set visibility:hidden
TweenLite.to(element, 2, {autoAlpha:0});

//in 2 seconds, fade back in with visibility:visible
TweenLite.to(element, 2, {autoAlpha:1, delay:2});

If your still having an issue.. please feel free to create a limited codepen demo example so we can test a live example.

 

 

Thanks :)

  • Like 1

Share this post


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

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. 


  • Recently Browsing   0 members

    No registered users viewing this page.

×