Jump to content
Search Community

Animations not working on reload

Sumanjit SenGupta test
Moderator Tag

Go to solution Solved by Rodrigo,

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've started with javascript and GSAP in my project. I've used Tweenlite.to() to change the opacity of some anchor tags.

 

The animations are working absolutely great the first time I'm opening the page. But if I reload the page, the tweens are not working. I'm closing the tab and opening the page in a new tab and its working again.

Why is it so?

 

 

<--HTML file-->

<html>

<head>

<script src="animations.js"></script>
</head>
<body>
...
...
<nav>
                                <a href="#" id="a_home" onMouseOver="inHome()" onMouseOut="outHome()">
                                Home
                                </a>
...
</nav>
...
...
</body>
</html>

 

<--animations.js-->

 

function inHome(){
TweenLite.to("#a_home",0.3,{css:{opacity: 1}});
}
function outHome(){
TweenLite.to("#a_home",1.5,{css:{opacity:0.7}});
}
Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

I wasn't able to replicate the behavior you described. My tests show the animation working fine on reload of the page.

I edited the pen only to make the effects more noticeable (added color and more extreme change in opacity)

 

I tested in Chrome and FireFox

 

http://codepen.io/GreenSock/full/IBsit/

 

If the problem persists please provide more details on how to replicate it.

 

Also please note that it is not necessary to wrap the properties inthe css{} object. The shorter code below will work fine:

function inHome(){
  TweenLite.to("#a_home",0.3, {opacity: 1});
}
function outHome(){
  TweenLite.to("#a_home",1.5, {opacity:0.7});
}
Link to comment
Share on other sites

  • Solution

Hi,

 

This is a very freaky behaviour that sometimes shows it's ugly face. I remember a couple of posts like this, please check the following posts and see if the solutions proposed there solve your issue:

 

http://greensock.com/forums/topic/6901-animated-scroll-to-anchor-tag/?p=25830

 

http://greensock.com/forums/topic/7817-reset-all-animations-when-returned-to-page/?p=29836

 

Rodrigo.

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