Jump to content
Search Community

Open a link after tweening

JobV 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

You can use event.preventDefault() to prevent link being clicked. Then use onComplete callback to go to that link.

 

$(".button").click(function(e){
  e.preventDefault();
  var url = $(this).attr('href');
  TweenMax.staggerTo(".button", 0.5, {opacity:0, y:-100, ease:Back.easeIn,
                                      onComplete: function(){
                                        window.location.href = url;                                           
                                      }

                                     }, 0.1);
});

 

 

See the Pen WXpOQm?editors=0010 by Sahil89 (@Sahil89) on CodePen

 

  • Like 5
Link to comment
Share on other sites

  • 3 years later...
On 11/10/2017 at 10:18 AM, Sahil said:

Hello! I'm newbie in java script, I have a problem apply this tutorial, I try to make it in Visual Studio, it turns out that I do the same of animating the navigation links and clicking on each link of "home" About Us "" Work "and" contact "and the animation works. But I get clicked appears an error : Cannot GET /.../ undefined. I don't know where that error is. If you can help me, thank you.

 

tutorial error.jpg

Link to comment
Share on other sites

It sounds like you're just passing an invalid URL in your onComplete to the window.location.href. In other words, your "url" parameter that's getting pulled from $(this).attr("href") is undefined. It's difficult to say for sure because you didn't provide a minimal demo, but this looks like just a JavaScript problem, nothing related to GSAP. 

  • Like 1
Link to comment
Share on other sites

Hello, thank you for your quick reply. I understand that I have an error in the JavaScript. I need to practice on that. I will make my own example and show it. I have not been used to writing the code. I will make an effort. Thanks once again.

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